On Mon, 2014-12-15 at 15:41 +0000, Maurice MILLS wrote: > I am using HttpComponents 4.3.1 in my project and have recently run into a > problem where PoolingHttpClientConnectionMananger is leaking HTTP > connections. Normally this doesn't pose a problem because they are cleaned > up after 60 seconds of TIME_WAIT, however we are creating > 30k threads and > this is causing us to pass the limit of available ports for the client > machine and the threads start failing. > > In my code I use an HttpPut to call my server. As described in the > documentation when I'm done, I do a reset(). Below is the stack trace that > shows where the problem is (PrsClientHttpResponse is my class): > > PoolingHttpClientConnectionManager.releaseConnection(HttpClientConnection, > Object, long, TimeUnit) line: 280 > ConnectionHolder.abortConnection() line: 132 > ConnectionHolder.cancel() line: 141 > HttpPut(AbstractExecutionAwareRequest).cancelExecution() line: 99 > HttpPut(AbstractExecutionAwareRequest).reset() line: 167 > PrsClientHttpResponse.close() line: 87 > > Steps: > ------- > > 1. ConnectionHolder line 141 calls ConnectionHolder.abortConnection() > > 2. ConnectionHolder line 125 (in abortConnection) calls > managedConn.shutdown to close the connection > > 3. ConnectionHolder line 132 (in the finally of abortConnection) then > calls manager.releaseConnection to release the connection > > 4. PoolingHttpClientConnectionManager line 280 calls pool.release with > the 2nd parameter = false (because the connection was just closed) > > 5. CPool line 311 removes the entry from the list of leased connections > > 6. CPool line 314 is false, so the entry is not readded to the list of > available connections (and therefore no longer referenced by the pool to be > cleaned up later) > > I have not found any methods on the classes that allow me do anything other > than what I have described. Am I doing something wrong? > > Thanks, > Maurice >
Maurice I am not sure I am seeing a connection leak here as the connection in question gets closed and correctly evicted from the pool. Please see an explanation of what TIME_WAIT is here http://wiki.apache.org/HttpComponents/FrequentlyAskedConnectionManagementQuestions Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org For additional commands, e-mail: httpclient-users-h...@hc.apache.org