Tcp连接挂起CLOSE_WAIT状态

[英]Tcp connections hang on CLOSE_WAIT status


Client close the socket first, when there is not much data from server, tcp connection shutdown is okay like:

客户端首先关闭套接字,当服务器没有太多数据时,tcp连接关闭就好了:

FIN -->
   <-- ACK
   <-- FIN, ACK
ACK -->

When the server is busying sending data:

当服务器忙于发送数据时:

FIN -->
    <-- ACK,PSH
RST -->

And the server connection comes to CLOSE_WAIT state and hang on there for a long time.

并且服务器连接进入CLOSE_WAIT状态并在那里挂了很长时间。

What's the problem here? client related or server related? This happens on Redhat5 for local sockets.

这有什么问题?客户相关或服务器相关?这种情况发生在Redhat5上,用于本地套接字。

This article talk about why "RST" is sent, but I do not know why the server connection stuck on CLOSE_WAIT, and do not send a FIN out.

本文讨论为什么发送“RST”,但我不知道为什么服务器连接卡在CLOSE_WAIT上,并且不发送FIN。

[EDIT]I ignored the most important information, this happens on qemu's slirp network emulation. It seems to be a problem of slirp bug for dealing with close connection.

[编辑]我忽略了最重要的信息,这发生在qemu的slirp网络仿真上。这似乎是处理密切连接的slirp bug的问题。

3 个解决方案

#1


2  

This means that there is unread data left in in the stream, that the client hasn't finished reading.

这意味着流中有未读数据,客户端尚未完成读取。

You can force it off by using the SO_LINGER option. Here's relevant documentation for Linux (also see the option itself, here), and [here's the matching function2] for Win32.

您可以使用SO_LINGER选项强行关闭它。这里是Linux的相关文档(这里也看到了选项本身),以及[这里是Win32的匹配函数2]。

It's the server side that is remaining open, so it's on the server side you can try disabling SO_LINGER.

它是服务器端保持打开状态,所以在服务器端你可以尝试禁用SO_LINGER。

#2


0  

It may mean that the server hasn't closed the socket. You can easily tell this by using "lsof" to list the file descriptors open by that process which will include TCP sockets. The fix is to have the process always close the socket when it's finished (even in error cases etc)

这可能意味着服务器尚未关闭套接字。您可以通过使用“lsof”列出由该进程打开的文件描述符(包括TCP套接字)来轻松告诉您。解决方法是让进程在完成时始终关闭套接字(即使在错误情况下等)

#3


0  

This a known defect for qemu.

这是qemu的一个已知缺陷。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.itdaan.com/blog/2009/12/16/180183c232b6f4907587d475e7714b76.html



 
© 2014-2018 ITdaan.com 粤ICP备14056181号