hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Teja Sai Krishna <saravit...@yahoo.com>
Subject Re: CLOSE_WAIT state at the client side
Date Fri, 21 Oct 2005 14:09:39 GMT
Hi Oleg,
 
If I use HTTP 1.0 i.e if i set method.setHttp11(false) this problem should be resolved? 
 
I mean CLOSE_WAIT state will be disappear automatically if I use HTTP 1.0 ?
 
Thanks
Teja


Oleg Kalnichevski <olegk@apache.org> wrote:
On Mon, Oct 17, 2005 at 06:12:46PM +0100, Teja Sai Krishna wrote:
> Thanks for your reply.
> 
> is method.releaseConnection() will not close these connections?. I thought releaseConnection
will take care of releasing the CLOSE_WAIT connections. method.releaseConnection() method
will not close the connections completely?.
>

The purpose of HttpMethod#releaseConnection() method is to inform the 
connection manager that the method no longer needs the connection. The 
connection manager may choose to close the connection depending upon the
connection reuse policy. Both standard connection managers (simple and
multithreaded), however, always attempt to keep connections alive per 
default (that is if HTTP/1.1 is being used and no 'connection: close' 
directive has been issued). 

> We are using default connection manager and not using any multithreadedConnection manager.

> 
> Do we need to implement multi threade connection manager to close these idle connections?
> 

No, you do not. One can easily use the idle connection handler on the
simple (non-pooling) connection manager. In your particular case,
though, you may consider writing a custom connection manager since you
seem to have application specific requirements as far as connection
management is concerned

Oleg



> My code looks like this.
> ---------------------
> 
> PostMethod method = new PostMethod(url.toExternalForm());
> DefaultMethodRetryHandler retryHandler = new DefaultMethodRetryHandler();
> retryHandler.setRetryCount(0);
> method.setMethodRetryHandler(retryHandler);
> HttpClient client = new HttpClient();
> client.setTimeout(rtimeout);
> try {
> method.setRequestBody(psRequestMsg);
> int statusCode = client.executeMethod(method);
> results = method.getResponseBodyAsString();
> }
> catch(ConnectException cex){
> 
> }catch(Exception e){
> 
> }finally{
> method.releaseConnection();
> }
> 
> ---------------------
> 
> Thanks
> Teja
> 
> Oleg Kalnichevski wrote:
> On Mon, Oct 17, 2005 at 04:48:04PM +0100, Teja Sai Krishna wrote:
> > Hi,
> > 
> > We have HTTP Client application that connects to the HttpListening Connector, which
runs on weblogic 8.1. I have observed some strange behaviour at my client side connection
states. Once the communication is over, some client side connections are in CLOSE_WAIT state.
Some times I have seen these CLOSE_WAIT connections will disappear after one day. But most
of the times it will not disappear even after one day. I have to kill my application. 
> > 
> > Is CLOSE_WAIT at the client side means, my client is waiting for final acknowledgement
from the server?
> > 
> 
> Not really. That means these connections have been closed by the server
> but the client still assumes they are valid and keeps them in the
> connection pool. The way to go is to implement a custom idle connection
> handler:
> 
> http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/util/IdleConnectionHandler.html
> 
> Hope this helps
> 
> Oleg
> 
> 
> 
> 
> > Thanks
> > Teja
> > 
> > 
> > Send instant messages to your online friends http://uk.messenger.yahoo.com 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org
> 
> 
> Send instant messages to your online friends http://uk.messenger.yahoo.com 

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


Send instant messages to your online friends http://uk.messenger.yahoo.com 
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message