Discussion:
Delphi Client/SocketServer application error...
(too old to reply)
z***@gmail.com
2014-01-29 16:20:03 UTC
Permalink
This question is about this message `"socket error: an existing connection was forcibly closed by the remote host (10054), on api 'recv'"`

We have a multitier application that we created using Delphi and uses Borland Socket Server on application server.

This solution is installed on several clients of ours, but with just one of them this problem happens. Not on a regular basis.

The application works well oiled almost the entire time, but once a while the client part hangs...

Debugging the client part I found out that this message appears before it freezes.

I installed WireShark to check the packets and this is what I found:

- The client sends a request to the server (PSH)
- The server does not send a acknowledge (ACK)
- The client sends a "TCP Retransmission" for 5 times
- Almost 20 seconds after the first packet the Wireshark shows an connection reset (RST)

wireshark log:

205 16:38:02.763757000 192.168.3.63 10.250.1.5 TCP 95 50567 > anet [PSH, ACK] Seq=1 Ack=1 Win=256 Len=41
208 16:38:03.124843000 192.168.3.63 10.250.1.5 TCP 95 [TCP Retransmission] 50567 > anet [PSH, ACK] Seq=1 Ack=1 Win=256 Len=41
212 16:38:03.725205000 192.168.3.63 10.250.1.5 TCP 95 [TCP Retransmission] 50567 > anet [PSH, ACK] Seq=1 Ack=1 Win=256 Len=41
224 16:38:04.925619000 192.168.3.63 10.250.1.5 TCP 95 [TCP Retransmission] 50567 > anet [PSH, ACK] Seq=1 Ack=1 Win=256 Len=41
243 16:38:07.318803000 192.168.3.63 10.250.1.5 TCP 95 [TCP Retransmission] 50567 > anet [PSH, ACK] Seq=1 Ack=1 Win=256 Len=41
310 16:38:12.119776000 192.168.3.63 10.250.1.5 TCP 95 [TCP Retransmission] 50567 > anet [PSH, ACK] Seq=1 Ack=1 Win=256 Len=41
346 16:38:21.725165000 192.168.3.63 10.250.1.5 TCP 54 50567 > anet [RST, ACK] Seq=42 Ack=1 Win=0 Len=0`

This happens on one machine at the time, while the remaining users work without any problem. That shows me that is not a problem with the SocketServer... Or is it?

I also found these lines on ScktComp.pas:

procedure TCustomWinSocket.DoOpen;
var
timeout: Integer;
begin
timeout := 100;
DoSetASyncStyles;
Event(Self, seConnecting);
// set the read(receive) timeout
SetSockOpt(FSocket, SOL_SOCKET, SO_RCVTIMEO, @timeout, SizeOf(timeout));
// set the send(write) timeout
SetSockOpt(FSocket, SOL_SOCKET, SO_SNDTIMEO, @timeout, SizeOf(timeout));
CheckSocketResult(WinSock.connect(FSocket, FAddr, SizeOf(FAddr)), 'connect');
...

Using ping to check the connection, I noticed some responses with more than 100ms or even 200ms. Can these timeouts (RCVTIMEO and SNDTIMEO) be the cause of all the problems?

Any help?

I am almost recoding the Delphi connection component trying to fix this, but I prefer not to.

Thanks a lot,

Z
z***@gmail.com
2014-01-30 16:02:35 UTC
Permalink
I've installed the Wireshark on the server and noticed that sometimes a packet sent by the client does not show on the server log, causing the retransmission and the reset... I think is due some network instability or configuration that is beyond my knowledge. How can I prevent this? Can anyone think of some way to resend a packet that does make the trip to the server?
Loading...