AsyncModbusTcpClient stops after ~30 seconds of inactivity #1187
-
Hello, I'm using python3-pymodbus/now 3.0.0-5 all from packages.debian.org with AsyncModbusTcpClient connected with an IP from modbus device and port=502. I already have a asyncio running loop and what I do is Is there any parameter to keep alive the connection or another approach? Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
First of all let me warn you, the version you are using have quite a number of bugs, 3.0.2 is the stable release. Did you read the docs ? https://pymodbus.readthedocs.io/en/v3.0.2/source/library/pymodbus.client.html#client-setup We do not have a keep-alive option, but it might be activated pr default at socket level, I do not remember. Personally I think your problem is something else. Pull requests are welcome. |
Beta Was this translation helpful? Give feedback.
-
Please add debug as per documentation (README), otherwise I do not have a clue what happens. Apart from the missing debug log, your example is quite nice and makes it easy to test. |
Beta Was this translation helpful? Give feedback.
-
I just ran your example:
Which makes me wonder if the problem is that your device disconnects. Most devices have a timeout builtin to break an unused connection. From my experience the timeout is normally around 20-30 seconds. Add logging and you will most likely see a message that the device closed the connection. The keep-alive option of tcp/ip will NOT help here, since it is on application level, the device needs a modbus request within its builtin timeout. |
Beta Was this translation helpful? Give feedback.
-
timeout did not really work in 2.5.3 and the timing in sync was quite different. |
Beta Was this translation helpful? Give feedback.
I just ran your example:
Which makes me wonder if the problem is that your device disconnects. Most devices have a timeout builtin to break an unused connection. From my experience the timeout is normally around 20-30 seconds.
Add logging and you will most likely see a message that the device closed the connection.
The keep-alive option of tcp/ip will NOT help here, since it is on application level, the device needs a modbus request within its builtin …