In BusinessWorks (BW), when performing massive HTTP requests over a short period, the following is occasionally seen: "java.net.BindException: Address already in use: connect" exception. Why is this error seen and how can it be resolved?
book
Article ID: KB0089620
calendar_today
Updated On:
Products
Versions
TIBCO ActiveMatrix BusinessWorks
-
Not Applicable
-
Description
Resolution: ustomer Description: =========== In BusinessWorks (BW), when performing massive HTTP requests over a short period, the following is occasionally seen: "java.net.BindException: Address already in use: connect" exception. Why is this error seen and how can it be resolved?
Environment: =========== Windows XP/ Windows 2003
Cause: =========== Background:
When a TCP connection is established, it implies that there will be a temporary port number adopted by the TCP client. This is called an ephemeral port.
Example: If performing two HTTP requests to a server named "test.com" (assuming the connection is not reused), there will be two connections established:
Here 2301/2302 are ephemeral ports in terms of TCP semantics.
Ephemeral ports usually are assigned from a limited pool. The size of the ports pool is per implementation. In Windows XP/ Windows 2003, the default pool resides in the gap from 1024 to 5000.
Background:
When an HTTP request is accomplished, the HTTP client shall call socket.close() to terminate the connection. However, this does not mean that the client port number of this TCP connection can be used by a new TCP connection. After the call to socket.close(), the client will enter the TIME_WAIT state in terms of TCP states. It must stay in the TIME_WAIT state for twice the maximum segment lifetime (MSL) until the client port is freed.
If performing many requests simultaneously the used client port numbers will also increase very quickly.
If there are no more client ports in the pool, the subsequent HTTP request will be assigned a number which is still in use. When BW is running within Windows XP/ Windows 2003, as the default pool size is less than 4000, the "java.net.BindException: Address already in use: connect" error may be seen.
This error is rarely seen under Linux/Unix operating systems because these operating systems usually have a larger ephemeral port range than Windows.
Resolution: ========
There are two workarounds for this issue:
A). Tweaking the ephemeral port range:
1). Start Registry Editor.
2). Locate the following subkey in the registry, and then click “Parameters”: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
3). On the Edit menu, click “New” and then add the following registry entry: Value Name: MaxUserPort Value Type: DWORD Value data: 65534 Valid Range: 5000-65534 (decimal) Default: 0x1388 (5000 decimal)
4). Description: This parameter controls the maximum port number that is used when a program requests any available user port from the system. Typically, ephemeral (short-lived) ports are allocated between the values of 1024 and 5000 inclusive.
5). Quit Registry Editor.
B). Force the connections to be reused across multiple requests.
By enabling the property bw.plugin.http.client.usePersistentConnectionManager, you can specify that a pool of HTTP connections to each HTTP server should be created so that connections can be reused by Send HTTP Request activities. In turn the total number of connections will be reduced significantly.
Issue/Introduction
In BusinessWorks (BW), when performing massive HTTP requests over a short period, the following is occasionally seen: "java.net.BindException: Address already in use: connect" exception. Why is this error seen and how can it be resolved?