Microsoft KB Archive/319502

= PRB: &quot;WSAEADDRESSINUSE&quot; Error Message When You Try to Connect Through an Anonymous Port After You Increase the IMAP Connection Limit =

Article ID: 319502

Article Last Modified on 6/18/2003

-

APPLIES TO


 * Microsoft TV Server 2.0 Service Pack 1

-



This article was previously published under Q319502



SYMPTOMS
When you increase the IMAP connection limit, and then try to connect to the IMAP server from a Microsoft TV mail service that is configured with a very low MailboxCacheTTL setting, you receive the &quot;WSAEADDRESSINUSE&quot; error message (Error code :10048).



CAUSE
This behavior occurs because of a combination of the following:
 * By default, Windows 2000 has limited space for anonymous ports. This space is limited more by the low MailboxCacheTTL that is configured for the Microsoft TV mail service. (Anonymous ports are temporary ports that are assigned by a computer's IP stack; anonymous ports are assigned from a designated range of ports. Only ports 1024-5000 are used in Windows 2000.)
 * The SO_REUSEADDR option on the sockets is not turned on, so the sockets cannot be reused immediately after being closed. The sockets must remain reserved in a TIME_WAIT state for four minutes. If you set the SO_REUSEADDR option, Windows permits multiple binds to the listening socket.

The anonymous port (ephemeral port) range limits the maximum number of connections from one computer to a specific service on a remote computer. The TCP/IP protocol uses the connection's 4-tuple (server IP, server port, client IP, and client port) to distinguish between connections; if the anonymous port range is only 4000 ports wide (approximately), there can be only 4000 unique connections from a client computer to a remote service at one time.

When the connection ends, the ephemeral port is available for reuse, although most IP stacks do not reuse that port number until the whole pool of ephemeral ports has been used. Therefore, if the client program reconnects, the client is assigned a different ephemeral port number for the client side of the new connection. In the case of the Microsoft TV mail service, a very low MailboxCacheTTL setting aggravates the situation because IMAP connections close and reopen frequently (on almost every request).

A port range of 4000 may seem large, but it is small for current computing demands when you consider that a TCP connection must expire through the TIME_WAIT state before it is really completed. For example, even if both sides of a connection properly close their ends of the connection, because of TCP's error control, each side must wait until the TIME_WAIT state is expired before the connection's resources really can be disposed.

The TIME_WAIT state is two times the maximum segment lifetime (MSL). (For this reason, the TIME_WAIT state is also known as the 2MSL state.) Typically, depending on the IP stack, the TIME_WAIT state is configured to be 240 seconds total. Therefore, you can have only 4000 connections per 240-second window and, in practice, these 4000 connections can be used up.



RESOLUTION
To prevent this behavior, do one of the following:  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:

 Start Registry Editor (Regedt32.exe). Locate the MaxUserPort key in the registry:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters 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)''' 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.

-or-</li> 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.</li></ul>

NOTE: This problem is made worse if the MailboxCacheTTL setting is very low. If the problem persists after you make the registry changes described previously, increase the mailbox TTL by changing the MailboxCacheTTL setting in the SiteConfig.cfg file (the configuration file for Microsoft Server Installation).

<div class="moreinformation_section">

MORE INFORMATION
For additional information about increasing the default anonymous port range, click the article numbers below to view the articles in the Microsoft Knowledge Base:

196271 Unable to Connect from TCP Ports Above 5000

149532 Windows NT Clients Run Out of Ports

Additional query words: WSAEADDRESSINUSE,Cache TTL,Anonymous Ports,MaxUserPort

Keywords: kbprb KB319502

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.