On Windows systems, when a server uses one or more Transmission Control Protocol/Internet Protocol (TCP/IP) sockets per transaction and the transaction rates are high, it is possible to run out of socket ports needed to create new socket connections. When socket ports run out, socket errors occur. The solution to this problem is to tune the TIMEWAIT-related Windows registry parameters:
- TcpTimedWaitDelay
- MaxUserPort
- StrictTimeWaitSeqCheck
The TIMEWAIT related Windows registry parameters control how long a socket port remains unavailable after it is closed and how many ports are available for use. Tune the TIMEWAIT registry parameters in the following situations:
- The netstat -a command indicates there are a large number (around 4000) of sockets in the TIMEWAIT state.
Follow the steps below to tune the TIMEWAIT registry parameters. All three parameters must have values added to the registry since Windows does not add the parameters by default. All three are added to the same registry subkey.
- Use regedit32 and go to subkey: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters
- Create a new REG_DWORD value named TcpTimedWaitDelay and set it to 0x1E (30 seconds), for example, to effect a quick turn around time for socket reuse. The default value is 240 seconds and the minimum value is 30 seconds.
- Create a new REG_DWORD value named MaxUserPort and set it to 0x8000 (32768), as an example, so TCP will have a much larger range of port numbers to assign for temporary socket connections. The default value is 5000 and the maximum value is 65534.
- Create a new REG_DWORD value named StrictTimeWaitSeqCheck and set it to 1, for example.
- Reboot the machine for the values to take effect.
As a reference for information regarding the TcpTimedWaitDelay and MaxUserPort TCP/IP Windows registry values, please visit Microsoft's Developer Network.