<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to ModbusFB ClientRequest: never recovers after a single ReplyTimeout (requires full download)</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/01fee79bf9/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/01fee79bf9/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/01fee79bf9/</id><updated>2026-06-19T13:44:03.977000Z</updated><subtitle>Recent posts to ModbusFB ClientRequest: never recovers after a single ReplyTimeout (requires full download)</subtitle><entry><title>ModbusFB ClientRequest: never recovers after a single ReplyTimeout (requires full download)</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/01fee79bf9/?limit=25#f345" rel="alternate"/><published>2026-06-19T13:44:03.977000Z</published><updated>2026-06-19T13:44:03.977000Z</updated><author><name>winki</name><uri>https://forge.codesys.com/u/winki/</uri></author><id>https://forge.codesys.com459a69d467acc532177b8458fc0ff0b7d3bdb7d0</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Library: ModbusFB (CODESYS Modbus package)&lt;br/&gt;
IDE / Runtime: CODESYS V3.5 SP___ / Control runtime ___&lt;br/&gt;
Target: ___ (e.g. gateway, Linux ARM64 / Debian)&lt;br/&gt;
Slave: Modbus TCP inverter&lt;/p&gt;
&lt;p&gt;Summary&lt;/p&gt;
&lt;p&gt;I poll a Modbus TCP slave with a permanent connection: one ClientTCP&lt;br/&gt;
(kept connected, xConnect:=TRUE) and one&lt;br/&gt;
ClientRequestReadHoldingRegisters, triggered cyclically.&lt;/p&gt;
&lt;p&gt;Everything works fine after a fresh application download. But as soon as&lt;br/&gt;
one single ReplyTimeout occurs (slave temporarily not answering), the&lt;br/&gt;
request never recovers. It stays stuck and no further messages are sent,&lt;br/&gt;
even though the TCP connection is still reported as alive. Only a full&lt;br/&gt;
application download brings it back — an online change or a runtime&lt;br/&gt;
reset is not enough / not what I want in production.&lt;/p&gt;
&lt;p&gt;State observed when stuck&lt;/p&gt;
&lt;p&gt;On ClientTCP (rClient):&lt;/p&gt;
&lt;p&gt;VariableValuexConnectTRUExConnectedTRUExErrorFALSEeErrorIDOKudiNumMsgSent23 (frozen, stops increasing)udiNumMsgReply0udiNumReplyTimeouts22udiNumReqNotProcessed0&lt;/p&gt;
&lt;p&gt;On the ClientRequest:&lt;/p&gt;
&lt;p&gt;VariableValueeErrorIDReplyTimeouteExceptionRESPONSE_SUCCESS_stateNoneuiStartItem50514uiQuantity54udiReplyTimeout500000 (µs)&lt;/p&gt;
&lt;p&gt;So the connection is alive, the request finished in ReplyTimeout, the FB&lt;br/&gt;
is back to _state = None, but udiNumMsgSent no longer increases — as if a&lt;br/&gt;
new rising edge on xExecute is no longer accepted / no longer produces a&lt;br/&gt;
new message.&lt;/p&gt;
&lt;p&gt;My trigger logic (simplified)&lt;/p&gt;
&lt;p&gt;Each PLC cycle, in this order:&lt;/p&gt;
&lt;p&gt;If the request is fully at rest (NOT xExecute AND NOT xBusy AND NOT xDone AND NOT xError) and a read is pending, I set xExecute := TRUE.&lt;br/&gt;
I call clientTcp() then clientRequest(rClient := clientTcp) once&lt;br/&gt;
each, per cycle.&lt;br/&gt;
On xDone or xError, I set xExecute := FALSE.&lt;/p&gt;
&lt;p&gt;I made sure to insert at least one full cycle with xExecute = FALSE&lt;br/&gt;
(seen by the FB call) before re-triggering, so the falling edge is processed.&lt;/p&gt;
&lt;p&gt;Questions&lt;/p&gt;
&lt;p&gt;After a ReplyTimeout (xError = TRUE), what is the exact, correct&lt;br/&gt;
sequence to re-trigger the same ClientRequest so a new message is&lt;br/&gt;
actually sent again? Is a full cycle with xExecute = FALSE between two&lt;br/&gt;
executions mandatory?&lt;br/&gt;
Is there a known condition where, after ReplyTimeout, the&lt;br/&gt;
ClientTCP keeps xConnected = TRUE but silently stops sending new&lt;br/&gt;
requests (e.g. an internal request queue / _udiRequestId that gets out&lt;br/&gt;
of sync)? udiNumMsgSent freezing at 23 while the FB shows _state = None is what puzzles me.&lt;br/&gt;
Is the recommended pattern to drop the connection (ClientTCP.xConnect := FALSE for one cycle, then TRUE) on a request error, rather than&lt;br/&gt;
keeping it alive? The docs state a request error does not close the&lt;br/&gt;
connection, so I kept it open — but maybe that is the issue here.&lt;br/&gt;
Could the large uiStartItem (50514) be relevant? It works right after&lt;br/&gt;
download, so addressing seems correct, but I want to rule it out.&lt;/p&gt;
&lt;p&gt;Any guidance on the canonical recovery pattern after a request timeout would&lt;br/&gt;
be greatly appreciated.&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>