|
|
View previous topic :: View next topic |
Author |
Message |
oxo
Joined: 13 Nov 2012 Posts: 219 Location: France
|
Modbus TCP |
Posted: Tue Aug 18, 2015 12:57 am |
|
|
Hi guys,
In the CCS modbus code, there is a 5 minute timeout in <modbus_app_layer_tcpip.c> in ModbusTCPTask(), case MODBUS_TCP_STATE_CONNECTED.
Any ideas why this is there? It contravenes the Modbuf Implementation guide http://www.modbus.org/docs/Modbus_Messaging_Implementation_Guide_V1_0b.pdf
Quote: | page 10 "It is recommended to keep the TCP connection opened with a remote device and not
to open and close it for each MODBUS/TCP transaction" |
|
|
|
RF_Developer
Joined: 07 Feb 2011 Posts: 839
|
Re: Modbus TCP |
Posted: Tue Aug 18, 2015 2:36 am |
|
|
oxo wrote: | Hi guys,
In the CCS modbus code, there is a 5 minute timeout in <modbus_app_layer_tcpip.c> in ModbusTCPTask(), case MODBUS_TCP_STATE_CONNECTED.
Any ideas why this is there? It contravenes the Modbuf Implementation guide http://www.modbus.org/docs/Modbus_Messaging_Implementation_Guide_V1_0b.pdf
Quote: | page 10 "It is recommended to keep the TCP connection opened with a remote device and not
to open and close it for each MODBUS/TCP transaction" |
|
Contravene is rather a strong word in this context. You can't contravene a recommendation. Also unless the specification specifies otherwise, I'd take the term "transaction" in the modbus context as being a command and response pair, not an open-ended connection, which I would term a "session", but I doubt Modbus, which was originally developed pre-TCP/IP, has such a concept.
I didn't design or write the CCS Modbus code, and it certainly has a few quirks and non-conformances, but the idea that any TCP connection, once opened, is there forever come what may, is nonsense. An inacticvity timeout, which is what a five minute timeout sounds like, sounds a very sensible precaution to me. Furthermore, if there really hasn't been any activity after that time, a transaction can hardly be said to be still taking place.
Given that, I'd suggest keeping the connection alive with an occasional "heartbeat" or "keepalive" command. Some read of a status register or something, every ten seconds or so maybe.
I certainly won't clamour for a change to the driver to remove what I feel to be a pretty sensible precautionary timeout. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19542
|
|
Posted: Tue Aug 18, 2015 2:43 am |
|
|
and in fact, I don't think the timeout even disagrees with the recommendation.
The recommendation is saying not to have a system that makes a connection, does one transaction, and then breaks the connection. Disconnecting if nothing at all is happening, does not disagree with this.... |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|