Search code examples
modbus

Modbus: The operation is not allowed on non-connected sockets


i am using to talk to a temperatur-sensor using modbus from: http://www.icpdas.com/products/PAC/i-8000/modbus.htm

Everything works fine but sometimes the ReadInputRegister creates an exception that says: „The operation is not allowed on non-connected sockets.“

Question: Is it possible that the module itself automatically closes a open session if is not used for a while?

Currently in my program i run an initialize at begin and save the handle in variable that i use if want to read or write via modbus.

Is it perhaps better to execute "init, read, close" always if i want to use it? So that i always creates a new handle?

Thx


Solution

  • Almost all Modbus devices I've encountered will close an idle connection after 10-15 seconds, which is likely what's happening in this case.