Field log (sensor behind 2.54.237.28:8234): normal replies avg 129 ms,
spikes up to 2.6 s handled. Then no reply at all to 19 requests in a
row while the TCP connection stayed "up" (sending never failed). The
sensor failed after 17 attempts and kept using the dead connection. A
dead mobile/NAT path isn't reported by the kernel for many minutes, and
keepalive only probes idle connections.
- TCP_USER_TIMEOUT 10 s (E2UART_TCP_USER_TIMEOUT_MS): sent data not
acknowledged by the gateway drops the connection.
- After 5 requests in a row (E2UART_NO_REPLY_RECONNECT) without a single
reply byte, the I/O thread ends ("No reply to 5 requests in a row -
reconnecting to the gateway"). validate() sees the lost link and opens
a new connection. Late data resets the count.
- closePort() frees the requests still queued for the closed connection.
- "NO reply" log lines (DEBUG_COMMUNICATION) and the reconnect error show
TCP_INFO: unacked data, retransmits, rtt, last ACK / last data received.
Unacked data and an old last ACK mean the network path is dead; ACKs
that keep coming mean the gateway/device side doesn't answer.
Tested with a fake device that goes silent after 3 replies while keeping
the TCP connection open: the reconnect came after the 5th unanswered
request, and requests 9-12 were answered on the new connection (ASan clean).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16