You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Jaikit Savla <ja...@yahoo.com> on 2013/10/25 08:33:33 UTC

Intermittent ConnectionClosedException with httpasynclient.

Hello Mates,

I am using Apache Async Httpclient 4.0 BETA3
Intermittently I am receiving ConnectionClosedException in my async failed callback. Looking at the async httpclient code - it returns ConnectionClosedException when data read is -1. Doc also says that "Signals that the connection has been closed unexpectedly.". Trying to understand at which end (server or client) connection was closed ? Can this be related to any tcp setting on client or server side which might be causing this ? 

Is it possible to detect this and retry request ?

Appreciate any pointers.

Thanks

stack trace:
org.apache.http.ConnectionClosedException: Connection closed

at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.endOfInput(HttpAsyncRequestExecutor.java:261)
at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:186)
at org.apache.http.impl.nio.DefaultHttpClientIODispatch.onInputReady(DefaultHttpClientIODispatch.java:125)
at org.apache.http.impl.nio.DefaultHttpClientIODispatch.onInputReady(DefaultHttpClientIODispatch.java:50)
at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:112)
at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:160)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:342)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:320)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:280)
at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:106)

Re: Intermittent ConnectionClosedException with httpasynclient.

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2013-10-24 at 23:39 -0700, Jaikit Savla wrote:
> Also one thing which is puzzling me is that most of the time (95%) this exception is returned in 0 - 1ms. 
> 
> 

Jaikit

This can usually happen when a persistent connection expires while being
leased from the pool. This can happen. The only way way to mitigate this
problem is to pro-actively evict persistent connections from the pool
after a certain period of inactivity. I would also strongly advise
upgrading to the latest SVN snapshot.

Oleg

> 
> On Thursday, October 24, 2013 11:33 PM, Jaikit Savla <ja...@yahoo.com> wrote:
>  
> Hello Mates,
> 
> I am using Apache Async Httpclient 4.0 BETA3
> Intermittently I am receiving ConnectionClosedException in my async failed callback. Looking at the async httpclient code - it returns ConnectionClosedException when data read is -1. Doc also says that "Signals that the connection has been closed unexpectedly.". Trying to understand at which end (server or client) connection was closed ? Can this be related to any tcp setting on client or server side which might be causing this ? 
> 
> Is it possible to detect this and retry request ?
> 
> Appreciate any pointers.
> 
> Thanks
> 
> stack trace:
> org.apache.http.ConnectionClosedException: Connection closed
> 
> at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.endOfInput(HttpAsyncRequestExecutor.java:261)
> at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:186)
> at org.apache.http.impl.nio.DefaultHttpClientIODispatch.onInputReady(DefaultHttpClientIODispatch.java:125)
> at org.apache.http.impl.nio.DefaultHttpClientIODispatch.onInputReady(DefaultHttpClientIODispatch.java:50)
> at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:112)
> at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:160)
> at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:342)
> at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:320)
> at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:280)
> at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:106)



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


Re: Intermittent ConnectionClosedException with httpasynclient.

Posted by Jaikit Savla <ja...@yahoo.com>.
Also one thing which is puzzling me is that most of the time (95%) this exception is returned in 0 - 1ms. 



On Thursday, October 24, 2013 11:33 PM, Jaikit Savla <ja...@yahoo.com> wrote:
 
Hello Mates,

I am using Apache Async Httpclient 4.0 BETA3
Intermittently I am receiving ConnectionClosedException in my async failed callback. Looking at the async httpclient code - it returns ConnectionClosedException when data read is -1. Doc also says that "Signals that the connection has been closed unexpectedly.". Trying to understand at which end (server or client) connection was closed ? Can this be related to any tcp setting on client or server side which might be causing this ? 

Is it possible to detect this and retry request ?

Appreciate any pointers.

Thanks

stack trace:
org.apache.http.ConnectionClosedException: Connection closed

at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.endOfInput(HttpAsyncRequestExecutor.java:261)
at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:186)
at org.apache.http.impl.nio.DefaultHttpClientIODispatch.onInputReady(DefaultHttpClientIODispatch.java:125)
at org.apache.http.impl.nio.DefaultHttpClientIODispatch.onInputReady(DefaultHttpClientIODispatch.java:50)
at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:112)
at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:160)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:342)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:320)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:280)
at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:106)