Modbus TCP generic request to keep connection open

Is there any type of generic NOP Modbus TCP request I, as a server, can send to the remote device and get nominal reply from it?
The issue I am trying to solve is connection timeout - the remote device closes connection after 5 seconds being idle, but I want it to persist using minimal data transfers possible. Thanks.
 
Before answering your question, we first need to clarify the terminology. In Modbus, the device that sends requests is the client. The remote device that responds to requests is the server.

Modbus does not have any generic NOP commands. However, it may be possible to resolve this issue at the TCP level, instead of at the higher Modbus protocol level. What you're describing seems to be the purpose of the TCP Keepalive message. Do you have the ability to configure the TCP Keepalive feature on your client (e.g. enable, time, interval, retries, etc.)?

If not, or if the Modbus server still closes the connection, despite sending keepalive messages, I recommend simply periodically (say, at least every 2.5 seconds) sending a Modbus read command (e.g. Function Codes 01 - 04). This has the added benefit of allowing useful data to be exchanged, resulting in a faster update rate of the data in your client.
 
Top