windows CLOSE_WAIT 状态问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6443831/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Issue with CLOSE_WAIT status
提问by Cyril Deba
I see a number of connections with CLOSE_WAIT status on my production server, and there are few questions. Please advice.
我在我的生产服务器上看到了许多处于 CLOSE_WAIT 状态的连接,并且几乎没有问题。请指教。
- I know that the windows register has the following parameter:
- 我知道windows寄存器有以下参数:
TcpTimedWaitDelayin the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
TcpTimedWaitDelay的在HKEY_LOCAL_MACHINE \系统\ CurrentControlSet \服务\ TCPIP \参数
According to the Microsoft stuff (http://social.technet.microsoft.com/Forums/en-US/windowsserver2008r2networking/thread/4288d218-fbf9-4489-b869-384a05dea83d/) , the value of the TIME_WAIT by default is 4 minutes. I set up the value in 30 seconds, but it looks like nothing is changed. Moreover, even after 4 mins CLOSE_WAIT connections are still there.
根据微软的资料(http://social.technet.microsoft.com/Forums/en-US/windowsserver2008r2networking/thread/4288d218-fbf9-4489-b869-384a05dea83d/),TIME_WAIT的默认值为4分钟. 我在 30 秒内设置了该值,但看起来没有任何变化。此外,即使 4 分钟后 CLOSE_WAIT 连接仍然存在。
My questions is how I can change the value of the TIME_WAIT, and see it in action? Should I restart my server?
我的问题是如何更改 TIME_WAIT 的值,并查看它的实际效果?我应该重新启动我的服务器吗?
- Is there any other settings to control the CLOSE_WAIT status in the Windows environment?
- Windows环境下有没有其他设置来控制CLOSE_WAIT状态?
Regards, Cyril
问候, 西里尔
回答by user207421
CLOSE_WAIT means that the peer has closed the connection and you haven't. The operating system is waiting for you(the local application) to close it.
CLOSE_WAIT 意味着对方已经关闭了连接,而你还没有。操作系统正在等待您(本地应用程序)关闭它。
So close it. Somewhere or other you have missed out.
所以关闭它。您错过了某个地方。
回答by Len Holgate
You're confusing CLOSE_WAIT
and TIME_WAIT
. They're not the same.
你很困惑CLOSE_WAIT
和TIME_WAIT
。他们不一样。
See here: http://www.serverframework.com/asynchronousevents/2011/01/time-wait-and-its-design-implications-for-protocols-and-scalable-servers.htmlfor some details on TIME_WAIT and why you might not really want to play with shortening the timeout.
请参阅此处:http: //www.serverframework.com/asynchronousevents/2011/01/time-wait-and-its-design-implications-for-protocols-and-scalable-servers.html有关 TIME_WAIT 的一些详细信息以及为什么可能真的不想玩缩短超时时间。
And see here: http://www.sunmanagers.org/pipermail/summaries/2006-January/007068.htmland here: http://blogs.msdn.com/b/spike/archive/2008/10/09/tcp-connections-hanging-in-the-close-wait-and-fin-wait-2-state.aspxfor details on why you might be collecting sockets stuck in CLOSE_WAIT
- in summary, you're possibly not closing your sockets correctly.
请参阅此处:http: //www.sunmanagers.org/pipermail/summaries/2006-January/007068.html和此处:http: //blogs.msdn.com/b/spike/archive/2008/10/09/ tcp-connections-hanging-in-the-close-wait-and-fin-wait-2-state.aspx详细了解为什么您可能会收集卡住的套接字CLOSE_WAIT
- 总之,您可能没有正确关闭套接字。
回答by user3260334
I Will suggest you to use Spring WS because I was facing same issue in my project and I switched to Spring Web Service than my problem resolved.
我会建议你使用 Spring WS,因为我在我的项目中遇到了同样的问题,我切换到 Spring Web 服务后我的问题解决了。
See the following code,
看下面的代码,
<bean id="viewCustomerInfo"
class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean"
p:serviceInterface="com.javaplex.CustomerInfoInterface"
p:wsdlDocumentUrl="http://127.0.0.1:8080/portal/CustomerInfoPort?wsdl"
p:namespaceUri="http://ws.customergen.com/" p:serviceName="CustomerInfo"
p:portName="CustomerInfoPort">
here is the complete article how to setup spring based beans which give your optimum performance.
这是完整的文章,如何设置基于 spring 的 bean 以提供最佳性能。
http://www.javaplex.com/spring-jax-ws-client-for-best-performance/
http://www.javaplex.com/spring-jax-ws-client-for-best-performance/