I working on a device communication protocol using TCP with TWSocketServer and TWSocket. (Delphi XE Project)

Small description: This device works with 2 sockets, i.e, it opens 2 sockets, one at a time. I have to answer correctly to the first connection and only then the second socket will connect. I have to answer correctly to the second connection and the communication start. Failing in answering will terminate the connection and another "session" will start.

The problem: The first socket is very active, i.e., the device sends every 5 seconds an "IsAlive" payload, date time, status, etc. The second on the other hand is idle. After 120s (or less) the second socket is closed and I'm loosing the "session", and I must restart the connection procedure all over again. Their support suggested I should configure Windows TCP SO_KEEPALIVE and so I did. I configured my application to send a keepalive every 30s. Wireshark reports TCP KeepAlive every 30 seconds, but still after 120s the socket is closed.

Keep alive sample: Client 1 connects in port 3423, client 2 in 3424

20507 1164.435227 192.168.1.76 192.168.1.250 TCP 55 [TCP Keep-Alive] 12000 → 3424 [ACK] Seq=6 Ack=17 Win=65536 Len=1 20508 1164.436457 192.168.1.250 192.168.1.76 TCP 66 [TCP Keep-Alive ACK] 3424 → 12000 [ACK] Seq=17 Ack=7 Win=5840 Len=0 SLE=6 SRE=7

Closing sequence: 21704 1253.076815 192.168.1.76 192.168.1.250 TCP 54 12000 → 3424 [FIN, ACK] Seq=7 Ack=17 Win=65536 Len=0 21705 1253.077097 192.168.1.76 192.168.1.250 TCP 66 59216 → 12000 [SYN] Seq=0 Win=64240 Len=0 MSS=1460 WS=256 SACK_PERM=1 21706 1253.078758 192.168.1.250 192.168.1.76 TCP 60 12000 → 59216 [RST, ACK] Seq=1 Ack=1 Win=0 Len=0 21708 1253.104825 192.168.1.250 192.168.1.76 TCP 60 3424 → 12000 [FIN, ACK] Seq=17 Ack=8 Win=5840 Len=0

I already tried to send a single byte ZERO to the device every 30s but the connection drops at the first attempt. The same happens if I answer ACK. The communication device support team already said the only way to keep the channel open is through TCP keep alive.

Do you know if there's an issue with Windows 10 1803 TCP KeepAlive? I read a lot of articles and some are pointing to Windows just ignoring keepalives. Others that Firewall might behave as such. I already deactivated both firewall and Windows Defender. The connection still get closed.

Running TCPView I manage to spot a System ID opening a high port (like 59216 in the above example) long enough to poke me in the eye and close the connection (TIME_WAIT).

Any suggestions? Is there another TCP settings to avoid connection closing? Is there a special setting in ICS ( TWSocketServer or TWSocket) to avoid idle connection close?

TIA, Clément


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to