网络连接不上, 有TCP错误, 如果操作系统是Windows Server 2003, 请尝试一下这里

Windows Server 2003 SP2 默认情况下, 用户可以使用的端口号仅有5000个. 系统自己预留了这五千中的1024个. 所以剩下三千九百多个connection就是这台机器的应用程序可以拥有的最多的连接数目了. Windows Server 2008 就没有这个默认端口上线为5000的限制了.

 

对于繁忙的系统, 比如说繁忙的Web前端去连SQL服务器, 三千九百个connection可能会不够用. 要么是连接数目太多, 要么是已经不用的连接还保持在Time_Wait的状态, 无法被系统回收并重复使用.

 

针对这种情况, 可以通过TCP View来查看当前机器的连接中有没有端口号在4996-4999之间的. 如果有, 并且还伴随有TCP错误的话, 那么很可能是端口不够用了. 解决方案是修改注册表MaxUserPortTcpTimedWaitDelay的值.

 

具体步骤和说明原文如下

============================

Increase the port range that is used for anonymous ports to approximately 20,000 ports (for example) by modifying the MaxUserPort registry key. Windows uses the conventional BSD range of 1024 to 5000 for its anonymous (ephemeral) port range. You can set only the upper bound of the ephemeral port range. To modify the MaxUserPort registry key, follow these steps:

  1. Start Registry Editor (Regedt32.exe).
  2. Locate the MaxUserPort key in the registry:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
  3. On the Edit menu, click Add Value, and then add the following registry value:
    Value Name: MaxUserPort
    Data Type: REG_DWORD
    Value: 65534 (for example)
    Valid Range: 5000-65534 (decimal)
    Default: 0x1388 (5000 decimal)
  4. Quit Registry Editor.

Description: This parameter controls the maximum port number that is used when an application requests any available user port from the system. Typically, ephemeral (that is, short-lived) ports are allocated between the values of 1024 and 5000 inclusive.

 

Change the timeout on the connections from 240 seconds (the default) to any length from 30 seconds to 300 seconds. Use the TcpTimedWaitDelay registry parameter to change this value. To do this, start Registry Editor (Regedt32.exe), locate the following key in the registry, and then modify the value:
HKEY_LOCAL_MACHINE\System\CurrectControlSet\services\Tcpip\Parameters
TcpTimedWaitDelay
Key: Tcpip\Parameters
Value Type: REG_DWORD-time in seconds
Valid Range: 30-300 (decimal)
Default: 0xF0 (240 decimal)
Description
:This parameter determines the length of time that a connection stays in the TIME_WAIT state when the connection is being closed. While a connection is in the TIME_WAIT state, the socket pair cannot be reused. For more information, see RFC 793.

 

参考资料

===========

http://support.microsoft.com/kb/319502

你可能感兴趣的:(windows)