hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ortwin Gl├╝ck <...@odi.ch>
Subject Re: Close_Wait problem
Date Wed, 14 Nov 2007 22:17:26 GMT

Pankaj Arora wrote:
> Hi,
> I am using a single instance of Http Client. I have implemented using a singleton and
each time a method is invoked something like this happens.
> public static HttpClient getClientInstance(){
>            HttpSingletonHolder.connectionManager.closeIdleConnections(20 * 1000);
>            return HttpSingletonHolder.client;
>     }
> Client.executeMethod();
> I was still facing close_Wait problem. So I added 
> public void releaseConnection(HttpConnection conn) {
>        conn.close();
>        super.releaseConnection(conn);
>     }
> in my MultithreadedConnectionManager.
> Strangely still see close_wait on Http. My use cases involves invoking server every one
minute in a while loop and problem happens every 14-15 hrs.
> Any suggestions?
> Thanks,
> Pankaj Arora


As I said, there is no active eviction. That means the idle connection are
closed when and only when you call closeIdleConnections(). You should do this
periodically in a Thread. In pseudo code that is:

new Thread() {
  public void run() {
      while (!Thread.interrupted()) {
        HttpSingletonHolder.connectionManager.closeIdleConnections(20 * 1000);


If you are only making one call every minute I don't see why you are using the
MultithreadedConnectionManager at all. Just create a new local HttpClient
instance each time, that's it. There is no point in keeping the instance around
in a singleton if you use it so rarely.


To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org

View raw message