I'm trying to figure out why my app's TCP/IP connection keeps hiccuping every 10 minutes (exactly, within 1-2 seconds). I ran Wireshark and discovered that after 10 minutes of inactivity the other end is sending a packet with the reset (RST) flag set. A google search tells me "the RESET flag signifies that the receiver has become confused and so wants to abort the connection" but that is a little short of the detail I need. What could be causing this? And is it possible that some router along the way is responsible for it or would this always come from the other endpoint?
我想弄明白为什么我的应用的TCP/IP连接每10分钟就会打嗝(确切地说,是1-2秒)。我跑Wireshark 10分钟后,发现不活跃的另一端与复位(RST)发送一个数据包标记集。谷歌搜索告诉我“重置国旗意味着接收机已经变得混乱,所以想中止连接”,但这是一个小的细节我需要。是什么导致了这种情况?有没有可能是某个路由器负责,或者这个总是来自另一个端点?
Edit: There is a router (specifically a Linksys WRT-54G) sitting between my computer and the other endpoint -- is there anything I should look for in the router settings?
编辑:在我的电脑和另一个端点之间有一个路由器(具体来说是Linksys WRT-54G)——我需要在路由器设置中查找什么吗?
6 个解决方案
#1
67
A 'router' could be doing anything - particularly NAT, which might involve any amount of bug-ridden messing with traffic...
一个“路由器”可以做任何事情——尤其是NAT,这可能会涉及到任何数量的被bug困扰的通信量……
One reason a device will send a RST is in response to receiving a packet for a closed socket.
设备发送RST的一个原因是为了响应收到一个封闭套接字的包。
It's hard to give a firm but general answer, because every possible perversion has been visited on TCP since its inception, and all sorts of people might be inserting RSTs in an attempt to block traffic. (Some 'national firewalls' work like this, for example.)
很难给出一个确切而笼统的答案,因为TCP从一开始就已经访问了每一个可能的异常,各种各样的人可能都在插入RSTs以阻止通信。(比如,有些“国家防火墙”的工作就是这样的。)
#2
18
Run a packet sniffer (e.g., Wireshark) also on the peer to see whether it's the peer who's sending the RST or someone in the middle.
运行一个数据包嗅探器(例如,Wireshark)也在对等点上,看看发送RST的是对等点还是中间的人。
#3
10
I've just spent quite some time troubleshooting this very problem. None of the proposed solutions worked. Turned out that our sysadmin by mistake assigned the same static IP to two unrelated servers belonging to different groups, but sitting on the same network. The end results were intermittently dropped vnc connections, browser that had to be refreshed several times to fetch the web page, and other strange things.
我刚刚花了很长时间来解决这个问题。所有提议的解决方案都没有奏效。结果发现,我们的系统管理员错误地将相同的静态IP分配给了属于不同组的两个不相关的服务器,但却位于同一个网络上。最终结果是间歇性地删除vnc连接、必须多次刷新以获取web页面的浏览器以及其他奇怪的东西。
#4
4
Some firewalls do that if a connection is idle for x number of minutes. Some ISPs set their routers to do that for various reasons as well.
如果连接空闲了x分钟,有些防火墙会这样做。一些isp为了各种原因设置它们的路由器。
In this day and age, you'll need to gracefully handle (re-establish as needed) that condition.
在这个时代,你需要优雅地处理(根据需要重新建立)这个条件。
#5
4
RST is sent by the side doing the active close because it is the side which sends the last ACK. So if it receives FIN from the side doing the passive close in a wrong state, it sends a RST packet which indicates other side that an error has occured.
RST是由一侧进行主动关闭的,因为它是发送最后一个ACK的边。因此,如果它从一侧接收FIN,在错误的状态下进行被动关闭,它会发送一个RST包,它指示错误发生的另一端。
#6
3
If there is a router doing NAT, especially a low end router with few resources, it will age the oldest TCP sessions first. To do this it sets the RST
flag in the packet that effectively tells the receiving station to (very ungracefully) close the connection. this is done to save resources.
如果有一个路由器在做NAT,特别是一个没有多少资源的低端路由器,它将会优先考虑最老的TCP会话。为此,它在包中设置RST标志,有效地告诉接收站关闭连接(非常不得体)。这样做是为了节省资源。
#1
67
A 'router' could be doing anything - particularly NAT, which might involve any amount of bug-ridden messing with traffic...
一个“路由器”可以做任何事情——尤其是NAT,这可能会涉及到任何数量的被bug困扰的通信量……
One reason a device will send a RST is in response to receiving a packet for a closed socket.
设备发送RST的一个原因是为了响应收到一个封闭套接字的包。
It's hard to give a firm but general answer, because every possible perversion has been visited on TCP since its inception, and all sorts of people might be inserting RSTs in an attempt to block traffic. (Some 'national firewalls' work like this, for example.)
很难给出一个确切而笼统的答案,因为TCP从一开始就已经访问了每一个可能的异常,各种各样的人可能都在插入RSTs以阻止通信。(比如,有些“国家防火墙”的工作就是这样的。)
#2
18
Run a packet sniffer (e.g., Wireshark) also on the peer to see whether it's the peer who's sending the RST or someone in the middle.
运行一个数据包嗅探器(例如,Wireshark)也在对等点上,看看发送RST的是对等点还是中间的人。
#3
10
I've just spent quite some time troubleshooting this very problem. None of the proposed solutions worked. Turned out that our sysadmin by mistake assigned the same static IP to two unrelated servers belonging to different groups, but sitting on the same network. The end results were intermittently dropped vnc connections, browser that had to be refreshed several times to fetch the web page, and other strange things.
我刚刚花了很长时间来解决这个问题。所有提议的解决方案都没有奏效。结果发现,我们的系统管理员错误地将相同的静态IP分配给了属于不同组的两个不相关的服务器,但却位于同一个网络上。最终结果是间歇性地删除vnc连接、必须多次刷新以获取web页面的浏览器以及其他奇怪的东西。
#4
4
Some firewalls do that if a connection is idle for x number of minutes. Some ISPs set their routers to do that for various reasons as well.
如果连接空闲了x分钟,有些防火墙会这样做。一些isp为了各种原因设置它们的路由器。
In this day and age, you'll need to gracefully handle (re-establish as needed) that condition.
在这个时代,你需要优雅地处理(根据需要重新建立)这个条件。
#5
4
RST is sent by the side doing the active close because it is the side which sends the last ACK. So if it receives FIN from the side doing the passive close in a wrong state, it sends a RST packet which indicates other side that an error has occured.
RST是由一侧进行主动关闭的,因为它是发送最后一个ACK的边。因此,如果它从一侧接收FIN,在错误的状态下进行被动关闭,它会发送一个RST包,它指示错误发生的另一端。
#6
3
If there is a router doing NAT, especially a low end router with few resources, it will age the oldest TCP sessions first. To do this it sets the RST
flag in the packet that effectively tells the receiving station to (very ungracefully) close the connection. this is done to save resources.
如果有一个路由器在做NAT,特别是一个没有多少资源的低端路由器,它将会优先考虑最老的TCP会话。为此,它在包中设置RST标志,有效地告诉接收站关闭连接(非常不得体)。这样做是为了节省资源。