Closed Tangerino closed 2 weeks ago
From the documentation: http://libmodbus.org/docs/v3.0.6/modbus_read_registers.html or http://libmodbus.org/docs/v3.1.4/modbus_read_registers.html
The modbus_read_registers() function shall return the number of read registers if successful. Otherwise it shall return -1 and set errno.
If not connected or read fails, try to reconnect and read again.
Remote devices/servers that fail often can drastically affect the total efficiency of the entire MODBUS network. Especially with RTU/serial networks. It is just the nature of a master/slave type of network.
From: Carlos Tangerino [mailto:notifications@github.com] Sent: Thursday, December 21, 2017 9:21 AM To: stephane/libmodbus libmodbus@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [stephane/libmodbus] Dead connections (#415)
How do we detect dead connections on a modbus server? How to avoid clients to connect and not send data or became unresponsive? Server may drop the connections from lazy clients. Thanks in advance
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/stephane/libmodbus/issues/415 , or mute the thread https://github.com/notifications/unsubscribe-auth/AAo5AXSH6sxTcu9UdFfo602UypJEa0IZks5tCmkxgaJpZM4RJ4hx . https://github.com/notifications/beacon/AAo5AXGx3bolubnyh0mv9uEZElXWyhaAks5tCmkxgaJpZM4RJ4hx.gif
Never mind, the multi client example does not handle timeouts if we connect AND do not send anything. That will allocate all available sockets. This solution is outside the library context. Anyway be aware that DOS attack is easy to reproduce. It would be nice to have a void *user_data in the context so we can associate a timer for instance for each connection and close an idle socket. I would change the SELECT call to accept a time out argument. Thank you.
->main The client connection from 192.168.1.4 is accepted Connecting to 192.168.1.100:102 Waiting for a indication...
Excuse me, what's the reason for this?
have you found the answer for this. I'm writing a server application and it works well. but if my client gets interrupted my slave program will hang and will not recover even if I cycle power on my client.
I deployed various Modbus servers powered by libmodbus and it's easy to close/open dead connections on error. The lib provides helpers (https://libmodbus.org/reference/modbus_set_error_recovery/)
How do we detect dead connections on a modbus server? How to avoid clients to connect and not send data or became unresponsive? Server may drop the connections from lazy clients. Thanks in advance