Modbus delay

I am seeing quite a bit of modbus delay in my network. Motions sensors are tripping, but not showing up in openhab because they are not read in time.

My config is:

poll=50

tcp.water.connection=10.88.64.45:502:0:600000:0:3:100
tcp.water.length=55
tcp.water.type=coil

tcp.basement.connection=10.88.64.46:502:0:600000:0:3:100
tcp.basement.length=55
tcp.basement.type=coil

tcp.basement_ponet.connection=10.88.64.46:502:0:600000:0:3:100
tcp.basement_ponet.start=2072
tcp.basement_ponet.length=8
tcp.basement_ponet.type=coil

tcp.first.connection=10.88.64.47:502:0:600000:0:3:100
tcp.first.length=55
tcp.first.type=coil

tcp.first_ponet.connection=10.88.64.47:502:0:600000:0:3:100
tcp.first_ponet.start=2072
tcp.first_ponet.length=8
tcp.first_ponet.type=coil

tcp.second.connection=10.88.64.48:502:0:600000:0:3:100
tcp.second.length=55
tcp.second.type=coil

tcp.second_ponet.connection=10.88.64.48:502:0:600000:0:3:100
tcp.second_ponet.start=2072
tcp.second_ponet.length=8
tcp.second_ponet.type=coil

tcp.shed.connection=10.88.64.49:502:0:600000:0:3:100
tcp.shed.length=55
tcp.shed.type=coil

tcp.shed_ponet.connection=10.88.64.49:502:0:600000:0:3:100
tcp.shed_ponet.start=2072
tcp.shed_ponet.length=8
tcp.shed_ponet.type=coil

I am not sure why I am seeing so many timeouts, it’s also like a single timeout also delays all the other reads, is this the case?

24-Jan-2018 17:28:18.981 [ERROR] [org.openhab.binding.modbus.internal.ModbusSlave   ] - ModbusSlave (first): Error getting modbus data for request net.wimpi.modbus.msg.ReadCoilsRequest@2e7d5541. Error: Executing transaction failed (tried 3 times). Endpoint ModbusTCPSlaveEndpoint@62e61e71[address=10.88.64.47,port=502]. Connection: TCPMasterConnection@a5ace1c[socket=Socket[addr=/10.88.64.47,port=502,localport=59024]]
24-Jan-2018 17:28:28.888 [ERROR] [org.openhab.binding.modbus.internal.ModbusSlave   ] - ModbusSlave (shed): Error getting modbus data for request net.wimpi.modbus.msg.ReadCoilsRequest@737d3501. Error: Executing transaction failed (tried 3 times). Endpoint ModbusTCPSlaveEndpoint@5e8dd21f[address=10.88.64.49,port=502]. Connection: TCPMasterConnection@72586f14[socket=Socket[addr=/10.88.64.49,port=502,localport=41698]]
24-Jan-2018 17:28:29.889 [ERROR] [org.openhab.binding.modbus.internal.ModbusSlave   ] - ModbusSlave (basement_ponet): Error getting modbus data for request net.wimpi.modbus.msg.ReadCoilsRequest@581f661c. Error: Executing transaction failed (tried 3 times). Endpoint ModbusTCPSlaveEndpoint@6e8671b1[address=10.88.64.46,port=502]. Connection: TCPMasterConnection@28788bf0[socket=Socket[addr=/10.88.64.46,port=502,localport=42856]]
24-Jan-2018 17:28:30.493 [ERROR] [org.openhab.binding.modbus.internal.ModbusSlave   ] - ModbusSlave (first): Error getting modbus data for request net.wimpi.modbus.msg.ReadCoilsRequest@6941fe7a. Error: Executing transaction failed (tried 3 times). Endpoint ModbusTCPSlaveEndpoint@62e61e71[address=10.88.64.47,port=502]. Connection: TCPMasterConnection@1e69d479[socket=Socket[addr=/10.88.64.47,port=502,localport=59422]]
24-Jan-2018 17:28:31.098 [ERROR] [org.openhab.binding.modbus.internal.ModbusSlave   ] - ModbusSlave (second_ponet): Error getting modbus data for request net.wimpi.modbus.msg.ReadCoilsRequest@61c21066. Error: Executing transaction failed (tried 3 times). Endpoint ModbusTCPSlaveEndpoint@1637f4b9[address=10.88.64.48,port=502]. Connection: TCPMasterConnection@303a8838[socket=Socket[addr=/10.88.64.48,port=502,localport=50210]]
24-Jan-2018 17:28:31.199 [ERROR] [.internal.pooling.ModbusSlaveConnectionFactoryImpl] - connect try 1/3 error: connect timed out. Connection TCPMasterConnection@23da111c[socket=Socket[unconnected]]. Endpoint ModbusTCPSlaveEndpoint@5e0d543f[address=10.88.64.49,port=502]
24-Jan-2018 17:28:31.206 [ERROR] [org.openhab.binding.modbus.internal.ModbusSlave   ] - ModbusSlave (water): Error getting modbus data for request net.wimpi.modbus.msg.ReadCoilsRequest@65b3c9d1. Error: Executing transaction failed (tried 3 times). Endpoint ModbusTCPSlaveEndpoint@4e3335e8[address=10.88.64.45,port=502]. Connection: TCPMasterConnection@2bbca4d0[socket=Socket[addr=/10.88.64.45,port=502,localport=54198]]
24-Jan-2018 17:29:08.901 [ERROR] [org.openhab.binding.modbus.internal.ModbusSlave   ] - ModbusSlave (shed): Error getting modbus data for request net.wimpi.modbus.msg.ReadCoilsRequest@7d93a2fd. Error: Executing transaction failed (tried 3 times). Endpoint ModbusTCPSlaveEndpoint@5e8dd21f[address=10.88.64.49,port=502]. Connection: TCPMasterConnection@23da111c[socket=Socket[addr=/10.88.64.49,port=502,localport=41770]]
24-Jan-2018 17:29:09.902 [ERROR] [org.openhab.binding.modbus.internal.ModbusSlave   ] - ModbusSlave (basement_ponet): Error getting modbus data for request net.wimpi.modbus.msg.ReadCoilsRequest@23882016. Error: Executing transaction failed (tried 3 times). Endpoint ModbusTCPSlaveEndpoint@6e8671b1[address=10.88.64.46,port=502]. Connection: TCPMasterConnection@692e0679[socket=Socket[addr=/10.88.64.46,port=502,localport=42934]]
24-Jan-2018 17:29:10.506 [ERROR] [org.openhab.binding.modbus.internal.ModbusSlave   ] - ModbusSlave (first): Error getting modbus data for request net.wimpi.modbus.msg.ReadCoilsRequest@7dd7ae1d. Error: Executing transaction failed (tried 3 times). Endpoint ModbusTCPSlaveEndpoint@62e61e71[address=10.88.64.47,port=502]. Connection: TCPMasterConnection@a3b7444[socket=Socket[addr=/10.88.64.47,port=502,localport=59484]]
24-Jan-2018 17:29:11.112 [ERROR] [org.openhab.binding.modbus.internal.ModbusSlave   ] - ModbusSlave (second_ponet): Error getting modbus data for request net.wimpi.modbus.msg.ReadCoilsRequest@7c4e4689. Error: Executing transaction failed (tried 3 times). Endpoint ModbusTCPSlaveEndpoint@1637f4b9[address=10.88.64.48,port=502]. Connection: TCPMasterConnection@72f6d44c[socket=Socket[addr=/10.88.64.48,port=502,localport=50276]]
24-Jan-2018 17:29:11.213 [ERROR] [.internal.pooling.ModbusSlaveConnectionFactoryImpl] - connect try 1/3 error: connect timed out. Connection TCPMasterConnection@3cfa74e[socket=Socket[unconnected]]. Endpoint ModbusTCPSlaveEndpoint@5e0d543f[address=10.88.64.49,port=502]
24-Jan-2018 17:29:11.221 [ERROR] [org.openhab.binding.modbus.internal.ModbusSlave   ] - ModbusSlave (water): Error getting modbus data for request net.wimpi.modbus.msg.ReadCoilsRequest@56701cba. Error: Executing transaction failed (tried 3 times). Endpoint ModbusTCPSlaveEndpoint@4e3335e8[address=10.88.64.45,port=502]. Connection: TCPMasterConnection@7abc8771[socket=Socket[addr=/10.88.64.45,port=502,localport=54270]]

This is the 1.x binding on openhab 2.1, would moving to the 2.x binding help speed things up?

That seems ambitious. Have you tried say 200mS polling, still responsive enough for most use cases?

I’d be inclined to put some interTransactionDelayMillis in there, maybe try the default of 60.

As you are holding open the TCP connections, I guess your system supports having that many open at once. I remember it as something potent.
(I guess the slaves that have multiple TCP connections also support it, some devices don’t - but I would expect that issue to show up every poll)

In my own multislave OH1 Modbus-TCP setup (sharing ethernet with CCTV and business traffic) I do get errors every 1500 to 10000 transactions. I suspect due to some mishandling somewhere on a busy network.
BUT they are always recovered on first retry, so not the same issue you have. It’s just an irritation I will tolerate until I get around to OH2 binding.

Except … due to limitations of the TCP-RS485 adaptors I use, I have setup to reconnect/disconnect TCP each transaction. Perhaps that is worth a try.


As the Modbus2 binding has been reworked extensively, it’s certainly worth trying it. It it is a non-trivial conversion though, introducing Things and Channels in OH2 style.
Putting that off for myself !

Yes, I think that is the case - the OH1 binding does one thing at a time, round-robin. Retries are completed before moving on to next device. So be wise to keep timeout periods relatively short!
OH2 may be cleverer?

Hi, Glad that I saw this posting, I experience similar problem, with @sipvoip whereas in my case, I only have one slave, and then I got error about thirty minutes to one hour after running the openhab runtime. In my case It cannot be recovered and it shows like follows:

2018-05-12 17:34:23.254 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 1/3 error: Connection timed out: connect. Connection TCPMasterConnection@10f3a86d[socket=Socket[unconnected]]. Endpoint ModbusTCPSlaveEndpoint@156ae5b4[address=192.168.1.101,port=502]
2018-05-12 17:34:44.319 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 2/3 error: Connection timed out: connect. Connection TCPMasterConnection@10f3a86d[socket=Socket[unconnected]]. Endpoint ModbusTCPSlaveEndpoint@156ae5b4[address=192.168.1.101,port=502]
2018-05-12 17:35:05.382 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 3/3 error: Connection timed out: connect. Connection TCPMasterConnection@10f3a86d[socket=Socket[unconnected]]. Endpoint ModbusTCPSlaveEndpoint@156ae5b4[address=192.168.1.101,port=502]
2018-05-12 17:35:05.382 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - re-connect reached max tries 3, throwing last error: Connection timed out: connect. Connection TCPMasterConnection@10f3a86d[socket=Socket[unconnected]]. Endpoint ModbusTCPSlaveEndpoint@156ae5b4[address=192.168.1.101,port=502]
2018-05-12 17:35:05.383 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - Error connecting connection TCPMasterConnection@10f3a86d[socket=Socket[unconnected]] for endpoint ModbusTCPSlaveEndpoint@156ae5b4[address=192.168.1.101,port=502]: Connection timed out: connect
2018-05-12 17:35:26.384 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 1/3 error: Connection timed out: connect. Connection TCPMasterConnection@f5964de[socket=Socket[unconnected]]. Endpoint ModbusTCPSlaveEndpoint@156ae5b4[address=192.168.1.101,port=502]
2018-05-12 17:35:47.445 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 2/3 error: Connection timed out: connect. Connection TCPMasterConnection@f5964de[socket=Socket[unconnected]]. Endpoint ModbusTCPSlaveEndpoint@156ae5b4[address=192.168.1.101,port=502]
2018-05-12 17:36:08.508 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 3/3 error: Connection timed out: connect. Connection TCPMasterConnection@f5964de[socket=Socket[unconnected]]. Endpoint ModbusTCPSlaveEndpoint@156ae5b4[address=192.168.1.101,port=502]
2018-05-12 17:36:08.508 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - re-connect reached max tries 3, throwing last error: Connection timed out: connect. Connection TCPMasterConnection@f5964de[socket=Socket[unconnected]]. Endpoint ModbusTCPSlaveEndpoint@156ae5b4[address=192.168.1.101,port=502]
2018-05-12 17:36:08.508 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - Error connecting connection TCPMasterConnection@f5964de[socket=Socket[unconnected]] for endpoint ModbusTCPSlaveEndpoint@156ae5b4[address=192.168.1.101,port=502]: Connection timed out: connect
2018-05-12 17:36:08.509 [WARN ] [.binding.modbus.internal.ModbusSlave] - ModbusSlave (slave1): Error getting a new connection for endpoint ModbusTCPSlaveEndpoint@156ae5b4[address=192.168.1.101,port=502]. Error was: Unable to validate object
2018-05-12 17:36:08.509 [WARN ] [.binding.modbus.internal.ModbusSlave] - ModbusSlave (slave1) not connected -- aborting read request net.wimpi.modbus.msg.ReadMultipleRegistersRequest@5ec747bc. Endpoint ModbusTCPSlaveEndpoint@156ae5b4[address=192.168.1.101,port=502]
2018-05-12 17:36:29.716 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 1/3 error: Connection timed out: connect. Connection TCPMasterConnection@51bc2fec[socket=Socket[unconnected]]. Endpoint ModbusTCPSlaveEndpoint@156ae5b4[address=192.168.1.101,port=502]
2018-05-12 17:36:50.779 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 2/3 error: Connection timed out: connect. Connection TCPMasterConnection@51bc2fec[socket=Socket[unconnected]]. Endpoint ModbusTCPSlaveEndpoint@156ae5b4[address=192.168.1.101,port=502]
2018-05-12 17:37:11.841 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 3/3 error: Connection timed out: connect. Connection TCPMasterConnection@51bc2fec[socket=Socket[unconnected]]. Endpoint ModbusTCPSlaveEndpoint@156ae5b4[address=192.168.1.101,port=502]
2018-05-12 17:37:11.841 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - re-connect reached max tries 3, throwing last error: Connection timed out: connect. Connection TCPMasterConnection@51bc2fec[socket=Socket[unconnected]]. Endpoint ModbusTCPSlaveEndpoint@156ae5b4[address=192.168.1.101,port=502]

My config looks like this:

poll="200"
service.pid="org.openhab.modbus"
tcp.slave1.connection="192.168.1.101:502"
tcp.slave1.id="1"
tcp.slave1.length="13"
tcp.slave1.start="0"
tcp.slave1.type="holding"
tcp.slave1.valuetype="uint16"
writemultipleregisters="true"

@sipvoip and @rossko57 Please help as I have tried to resolve this issues for weeks. Perhaps, you can provide recommendation on the below parameters, as I set them now to default :
interTransactionDelayMillis, optional, in milliseconds, default 60
reconnectAfterMillis, optional, in milliseconds, default 0
interConnectDelayMillis, optional, in milliseconds, default 0
connectMaxTries, optional, default 3
connectTimeout, optional, in milliseconds, default 0

Dear @ssalonen
I saw that you are the Modbus binding guru and quite active in Modbus binding posting, please help on my issues above. The binding that I use now is 1.9.0Released version and Openhab version that I use now is Openhab2.
Is the Modbus binding 1.9.0 is not compatible with Openhab2 and I should wait for Modbus binding 2.x.x ?

Hi!

The older version is compatible as well.

Personally I would probably go with the newer version at this stage. The code is being reviewed by maintainers already so it should get included in the standard openHAB distribution in the coming months. When that happens, the old version will be considered “deprecated”.

Best
Sami

1 Like

Dear @ssalonen
Thanks for your answer. I am in the same project with @Martin_K. Would like to extend the question.

So we are using openHAB to connect to a Omron PLC via Modbus to control a home.
It will work for about 8 hours and this error would come up:

2018-05-12 17:36:08.508 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] -
Error connecting connection TCPMasterConnection@f5964de[socket=Socket[unconnected]] for endpoint ModbusTCPSlaveEndpoint@156ae5b4[address=192.168.1.101,port=502]: Connection timed out: connect

Also I noticed that the memory usage of the OpenHAB program increases by about 100 MB per hour.
After about 8 hours, it would cause a fatal error in the PLC, however the OPENHAB program still runs, although the computer is slow due to the memory leak.

I only use Modbus binding for this project. Is there a way we can monitor the traffic dump of the modbus communication? So to determine the cause of the memory increase:
In your experience,

  1. is there a way to find out the leak?
  2. Is the leak caused by wrong data sent back from the PLC?
  3. Can the leak be caused due to network congestion in the network architecture? (As CCTV infra is also installed using the same network)

Any advice much appreciated !

Have you tried the new openHab 2 binding?

It might be normal that memory increases, depending how the java heap size has been configured, for example.

Connection timeout means connection timeout, so there is no modbus communication happening between the devices if that is the only thing you get. It’s possible to monitor tcp traffic with specialized tools (wireshark).

Troubleshooting memory issues and tuning the java virtual machine (JVM) is a whole another issue.

I’m afraid I can’t get to the details (too time consuming). I hope you get answers from here.

I suggest opening new threads since the original problem introduced in this thread was already closed/resolved/explained. These new questions are irrelevant to the original title and get hidden…

Best
Sami