Methods for modifying the time_wait parameters (modified on the server side)
Under Windows in Hkey_local_machine/system/currentcontrolset/services/tcpip/parameters, add the name TcpTimedWaitDelay
DWORD key, set to 30, to shorten the wait time for time_wait
Workaround for Close_wait: (Modified at client)
1 The general reason is that the TCP connection does not call the Close method. Needs to be applied to handle network link shutdown.
2 This is the reason for Web requests, often because response's bodystream did not call close.
For example, under Widnows:
Use HttpWebRequest Make sure that the GetRequestStream and GetResponse objects are closed, otherwise it is easy to cause the connection to be in the close_wait state
3 TCP keeplive function, can let the operating system for us to automatically clean off the close_wait connection.
However, Keeplive is 7,200 seconds under the Windows operating system, or 2 hours to clean it up. Often does not meet the requirements. The value can be adjusted smaller.
The adjustment method under Windows is
The following three parameters under Hkey_local_machine/currentcontrolset/services/tcpip/parameters:
KeepAliveInterval, set its value to www.2cto.com
KeepAliveTime, set its value to 300000 (in milliseconds, 300000 for 5 minutes)
TcpMaxDataRetransmissions, set its value to 5
Issues raised by close_wait:
Close_wait will take up a connection and the network can have a small connection. Too many, may cause network performance degradation, and occupy the system non-paged memory. Especially in the case of a connection pool (e.g. HttpRequest)
The number of network connections that will drain the connection pool, causing the network connection to not be established
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]
"KeepAliveTime" =dword:006ddd00
"KeepAliveInterval" =dword:000003e8
"MaxDataRetries" = "5″
Troubleshoot Time_wait and Close_wait methods under Windows