为什么我的客户端服务器套接字连接保持断开连接(Why does my Client Server Socket Connection Keep Disconnecting)
我使用套接字在C#.NET中有一个客户端服务器应用程序编写器。
我经常收到日志消息(比如每小时4次)说这个消息,
An existing connection was forcibly closed by the remote host
在这种情况下,错误发生在'服务器'端。
我决定使用wireshark来分析发生的事情,我得到了这个。 没有延迟,这一切都在几秒钟内发生。
Server > Client [PSH, ACK] Seq=55653 Ack=4472 Win=63940 Len=148 Client > Server [ACK] Seq=4472 Ack=55801 Win=4038 Len=0 Server > Client [PSH, ACK] Seq=55801 Ack=4472 Win=63940 Len=148 Client > Server [ACK] Seq=4472 Ack=55949 Win=4001 Len=0 Server > Client [PSH, ACK] Seq=55949 Ack=4472 Win=63940 Len=142 Client > Server [PSH, ACK] Seq=4472 Ack=55949 Win=4001 Len=31 Client > Server [RST, ACK] Seq=4503 Ack=55949 Win=0 Len=0
所以客户端和服务器之间发送东西(PSH)和确认东西(ACK)。 突然之间RST正在发生。 这根据维基百科是一个重置,并且这个重置对应于'我现在得到的'现有连接是强制的''消息。
这是什么意思? 这是否意味着重置导致问题? 我认为答案是否定的,更有意义的是重置是问题的结果? 即服务器端的套接字由于某种原因而死亡,并且客户端将重置发送到服务器以尝试唤醒它。
思考?
I have a client server application writter in C# .NET using Sockets.
I often get log messages (say about 4 per hour) saying this message,
An existing connection was forcibly closed by the remote host
In this case here the error is occuring on the 'server' side.
I decided to use wireshark to analyse what is occuring, and I get this. There are no delays, this is all happening within a couple of seconds.
Server > Client [PSH, ACK] Seq=55653 Ack=4472 Win=63940 Len=148 Client > Server [ACK] Seq=4472 Ack=55801 Win=4038 Len=0 Server > Client [PSH, ACK] Seq=55801 Ack=4472 Win=63940 Len=148 Client > Server [ACK] Seq=4472 Ack=55949 Win=4001 Len=0 Server > Client [PSH, ACK] Seq=55949 Ack=4472 Win=63940 Len=142 Client > Server [PSH, ACK] Seq=4472 Ack=55949 Win=4001 Len=31 Client > Server [RST, ACK] Seq=4503 Ack=55949 Win=0 Len=0
So the client and server are sending stuff between themselves (PSH) and acknowledging stuff (ACK). All of a sudden a RST is occuring. This according to wikipedia is a reset, and this reset corresponds to the 'An existing connection was forcibly ...' message I get above.
What really does that mean though? Does this mean that the reset causes the issue? I think the answer to that is no, and what would make more sense is that the reset is a result of the issue? I.e. The socket on the server side dies for some reason, and the client sends the reset to the server to kind of try and wake it up.
Thoughts?
原文:https://stackoverflow.com/questions/3098652