TCP Modbus not working from 1.6.2 to 1.7.1

Hi,
We have a serial line with 18 modbus devices. The serial modbus works very poor. In many cases not possible to send a command to device. Lots of CRC errors and etc. Same in 1.6.2 to 1.7.1.
I get TCP Modbus gateway. Works well till I try to use it with OH1.7.1
On one IP addres I have several IDs. On one ID I have up to 2 types (coil and holding)
After a day of tests the results are:
Only one coil can work in same time on one IP .
No one holding type works. I sniff the communication and protocol request and response are ok but always “ModbusSlave error getting responce from slave”. It was working on serial.
Does anyone use Modbus for any real applications?

I use it quite a bit, I have not tried 1.7.1, but it is working fine on the 1.7 snap I used to build my custom version to get rid of the state change on every pool interval. Try this one and let me know if it works.

Hi,
I just test the suggested file. The problem still exists.
[.b.modbus.internal.ModbusSlave] - ModbusSlave error getting responce from slave
If I test every node alone, It is working well. THe problem is with pooling proccess of many nodes.

Hello,
are there maybe news about this topic ? I’m experiencing the same problem …

thank you

Hi,
No any solutions till now. I reporting this problem since 1.6.2. Thay using external lib for serial communication. Now I check the situation with Modbust TCP. The same problem. Problem is in the pooling proccess, not in communications libs.
The new problem: after a several hours of working, the pooling proccess just stop and need OH restart. OH 1.6.2 to 1.7.1.
I can provide a real IP address with real modbus TCP nodes for tests.

Hello and thanks for answering.

For info, the problem I’m encountering with details is depicted in post 3928:

You say that “Problem is in the pooling proccess, not in communications libs”, can you help me please in understanding what does that mean ? Ar you sure that the .jar bindings of version 1.7.1 are correct ?

If so, no one is nowadays openhab to control any PLC via MODBUS ? :-o

Thanks again
Lorenzo

Hi Lorenzo,
For my experience (last 1 year with OH&Modbus), you are absolutly right. No one use Modbus in real case. I have relays, temp&hum sensors, dimmers, IOs on modbus. All works well with any other systems except OH. When connect one node on the table it’s looks like working, but If you try to make some real production system… not possible.
I was checked your post before. The problem is same and not resolved till now.
I thinking to move to another platform. The list of binding in OH is huge, but if not working well …
I checking the Home Assistant now.

Hello,
thank you for your infos.

Are you getting good results integrating Home Assistant with Modbus ?

What are the other systems are you using at the moment with Modbus ? Is there a solution for a “rookie programmer” you can suggest ?

Best regards
Lorenzo

Hi,
just to add some infos:

  1. the problem occurs even with just a slave (independently if it is DI or DO, after some polling the PLC get disconnected and does not reconnect)
  2. With the NetworkHealth Binding I’ve found that first the connection on port 502 get lost and then the one with port 80 (but the PLC is always pingable)
  3. some parameters in .config apparently does not have any effect on the behaviour:
    modbus:tcp.slave1.poll=5200 and modbus:slave1.valuetype=bit

Unfortunately just bad news …

Hi,
In OH the pool parameter is not per node. This parameter is for all modbus nodes and you canonly set like this: modbus:poll=
This parameter works correct.
The TCP and Serial Modbus binding really disconnect after several hours and not reconnect. Need restart. I solve it with System CronJob restart (every 3 hours). Not good idea, but solve the problem.

Hi,
I also tried that workaround: disabling and reenabling the network card of the PC where OH is running but it requires more or less 1 minute: a lot of time.
DO you restart the whole PLC and maintain variables values with persistency ?

Thank you !

I restart the OpenHab at all.

Hello,
I do not know if I’m proceeding in the right direction …

The disconnection appears after the log message "“ModbusSlave error getting responce from slave” which can be found in the bindings at: org.openhab.binding.modbus-1.7.1.jar -> org.openhab.binding.modbus.internal -> ModbusSlave.class.

This message is logged after calling a method (do not know if this is the right name) “resetConnection();” which seems to close the connection:

public void resetConnection()
{
if (connection != null) {
connection.close();
}
connection = null;
}
}

Is it maybe possible to try to restart the connection there ?

Maybe someone has aleady worked on this code ?

Thank you !

Hello !

(Just for info , hoping that it could be of interest for someone :slight_smile: )

The Modbus Binding v. 1.7.1 seems to run much better on a Linux maschine (the UDP connection with port 502 looks definetely better)

Hi,
All my tests are on Linux Ubuntu.

Hi, now my sistem is up since 24 hours and deeply tested. My machine has also Ubunto, is connected to the MODBUS via a CAT5 UTP cable. The connection on the UDP port 502 seems to be continuos and stable.
Please tell me if I can profide you furter info.
Ciao

Hello !
I’ve kind of deeply tested modbus tcp binding on different platforms: mainly ubuntu and raspberry.

Here my personal conclusions:

  1. Actually OH sometimes disconnect sending the message “error gettint responce from slave”.
    It happens that after sometimes the system reconnect but it may require sone time (even minutes)
  2. Rebooting the system requires more or less 45 seconds on raspberry PI
  3. The NH (Network health) binding is not reliable as well. Very often openhab lost the connection on modbus port (502) but still OH can communicate with PLC.

Lorenzo

Hi,

I’ve implemented several connection closing fixes in my pull request. I think this might help with the issues like this.

Hi,
I’'m using serial Modbus connection with about 15 nodes. Please provide me somethig for tests. I can give you detailed feedback or remote access for real tests and monitoring.

Hi lgeorgiev, can you explain what you mean by nodes? I though the current serial modbus implementation has issues when there are many slaves defined in openhab.cfg.