hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maurice MILLS <maurice.mi...@externe.bnpparibas.com>
Subject RE: PoolingHttpClientConnectionManager leaking connections
Date Tue, 16 Dec 2014 16:52:16 GMT
Hello Oleg,

I'm sorry, I misstated the problem.  The problem is that in the sequence below, the connection
is closed and not put back into the pool for reuse (which remains open until it is closed
after the TIME_WAIT expires).

How can I just put the connection back into the list of available connections so it can be
reused?  I don't see anywhere in the objects available to do that.


-----Original Message-----
From: Oleg Kalnichevski [mailto:olegk@apache.org] 
Sent: mardi 16 d├ęcembre 2014 09:35
To: HttpClient User Discussion
Subject: Re: PoolingHttpClientConnectionManager leaking connections

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(HttpClientConnect
> ion, 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

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


To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org

This message and any attachments (the "message") is
intended solely for the intended addressees and is confidential. 
If you receive this message in error,or are not the intended recipient(s), 
please delete it and any copies from your systems and immediately notify
the sender. Any unauthorized view, use that does not comply with its purpose, 
dissemination or disclosure, either whole or partial, is prohibited. Since the internet 
cannot guarantee the integrity of this message which may not be reliable, BNP PARIBAS 
(and its subsidiaries) shall not be liable for the message if modified, changed or falsified.

Do not print this message unless it is necessary,consider the environment.


Ce message et toutes les pieces jointes (ci-apres le "message") 
sont etablis a l'intention exclusive de ses destinataires et sont confidentiels.
Si vous recevez ce message par erreur ou s'il ne vous est pas destine,
merci de le detruire ainsi que toute copie de votre systeme et d'en avertir
immediatement l'expediteur. Toute lecture non autorisee, toute utilisation de 
ce message qui n'est pas conforme a sa destination, toute diffusion ou toute 
publication, totale ou partielle, est interdite. L'Internet ne permettant pas d'assurer
l'integrite de ce message electronique susceptible d'alteration, BNP Paribas 
(et ses filiales) decline(nt) toute responsabilite au titre de ce message dans l'hypothese
ou il aurait ete modifie, deforme ou falsifie. 
N'imprimez ce message que si necessaire, pensez a l'environnement.
View raw message