Hi,
Thanks for the tip, it solve my issue. 
However there is one point I still don't understand.
Say I used a connection, and returned it to the pool.
During the time the connection is in the pool, the server sent a FIN message, 
so the socket changed to CLOSE_WAIT.
Now when I need to send another request to the same address, I would expect the 
pool to get that connection, check it and see that it should be closed, close 
it (send FIN to the server), create a new connection and return it to me.
If that was the case then there would have been times where I would see 
connections in CLOSE_WAIT but when new request appear they should have 
disappeared.
What I saw is the number of CLOSE_WAIT sockets raising all the time and when a 
socket reached that state it was never released.

What am I missing?
Regards,
Nir

-----Original Message-----
From: Oleg Kalnichevski [mailto:[email protected]] 
Sent: Wednesday, February 19, 2014 1:18 PM
To: HttpClient User Discussion
Subject: Re: connections left in CLOSE_WAIT state

On Wed, 2014-02-19 at 10:33 +0000, Nir Dweck wrote:
> Hi,
> I am using httpclient version 4.2.3.
> I did a split proxy, which receives an HTTP requests, opens its body in order 
> to log its content and then sends the content in two requests, one for the 
> local host server and the other to a different server running a newer version 
> of our software.
> this is the code I used to create the http client:
>                         PoolingClientConnectionManager mngr = new 
> PoolingClientConnectionManager();
>                         mngr.setMaxTotal(400);
>                         mngr.setDefaultMaxPerRoute(200);
>                         m_http = new DefaultHttpClient(mngr);
>                         
> m_http.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "phytech 
> proxy");
>                         
> m_http.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 
> 10000);
>                         
> m_http.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, 
> 5000);
> 
> When I need to send a request to the remote host, I take a thread from a 
> thread pool which will perform the operation asynchronously.
> The proxy and the old server are running windows and the new server is on a 
> Linux machine.
> The problem is I get tones of connections with the remote server which are 
> stuck in CLOSE_WAIT state and never get released (none with the local host - 
> I think it is related to the fact the local machine is windows).
> When I look at the sniffer I don't see any FIN message coming out of my 
> client, although I set SO_TIMEOUT to 5 seconds and there were more than 5 
> seconds of inactivity.
> Any idea what am I doing wrong and how to solve it?
> Thanks,
> Nir

Most likely you need to pro-actively evict stale / idle connections from the 
connection pool

http://hc.apache.org/httpcomponents-client-4.2.x/tutorial/html/connmgmt.html#d5e652

Oleg 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to