Details
Description
I have an application that rapidly makes requests using HttpClient. When the number of sockets in TIME_WAIT exceeds the MaxUserPort setting (default 5000) the following exception is reported....
WARNING: CONNECTION FAILED on HttpExchange@28052805=POST//149.59.210.196:50001/services/Logger#1
java.net.BindException: Address already in use: connect
at sun.nio.ch.Net.connect(Native Method)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:507)
at org.mortbay.jetty.client.SelectConnector.startConnection(SelectConnector.java:69)
at org.mortbay.jetty.client.HttpDestination.startNewConnection(HttpDestination.java:241)
at org.mortbay.jetty.client.HttpDestination.doSend(HttpDestination.java:468)
at org.mortbay.jetty.client.HttpDestination.send(HttpDestination.java:418)
at org.mortbay.jetty.client.HttpClient.send(HttpClient.java:142)
at com.philips.nmrs.communicationsbus.HTTP_MessageRouter.httpSend(HTTP_MessageRouter.java:217)
at com.philips.nmrs.communicationsbus.HTTP_MessageRouter.routeMessage(HTTP_MessageRouter.java:165)
at com.philips.nmrs.communicationsbus.MessageRouterWorker.run(MessageRouterWorker.java:29)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
The HttpClient is using Synchronous Request:
httpSend(exchange);
exchange.waitForDone();
When the above exception is thrown, waitForDone() never ends nor throws any exception. I am able to get around this issue by increasing the MaxUserPort setting and decreasing the TcpTimedWaitDelay to 30 seconds (via the registry)
This has been fixed as part of the review of the waitForDone() logic made in 6.1.22.