You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Adrian Cole <ad...@gmail.com> on 2009/05/03 00:14:46 UTC

fatalIOException: Connection Reset

I have a project: jclouds which uses the following version of httpnio:
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore-nio</artifactId>
            <version>4.0</version>
        </dependency>

I have a connection
pool<http://code.google.com/p/jclouds/source/browse/trunk/extensions/httpnio/src/main/java/org/jclouds/http/httpnio/pool/HttpNioFutureCommandConnectionPool.java>
which
implements EventListener<http://hc.apache.org/httpcomponents-core/httpcore-nio/apidocs/org/apache/http/nio/protocol/EventListener.html#fatalIOException(java.io.IOException,%20org.apache.http.nio.NHttpConnection)>.
 Now, this application is mainly used to connect to Amazon S3.  I often get
IOExceptions like below for connection reset by peer.  However, they are
coming in as fatalIOException.  This seems to imply a complete shutdown of
the IOReactor.  My first impression is this is too severe, as re-creating an
IOReactor over a connection reset seems a bit harsh.  However this is the
current behaviour.  Do you have any ideas on how I can work around
connection resets in a simple way?

Best regards,

Adrian Cole

Here are some details:

http://code.google.com/p/jclouds/issues/detail?id=14

SEVERE: [closed]-31222126{s3.amazonaws.com/72.21.202.112:80} - io error
java.io.IOException: Connection reset by peer
at sun.nio.ch.FileDispatcher.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:21)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:233)
at sun.nio.ch.IOUtil.read(IOUtil.java:206)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:236)
at
org.apache.http.impl.nio.reactor.SessionInputBufferImpl.fill(SessionInputBufferImpl.java:94)
at
org.apache.http.impl.nio.codecs.AbstractMessageParser.fillBuffer(AbstractMessageParser.java:127)
at
org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:156)
at
org.apache.http.impl.nio.DefaultClientIOEventDispatch.inputReady(DefaultClientIOEventDispatch.java:146)
at
org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:153)
at
org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:314)
at
org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:294)
at
org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:256)
at
org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:96)
at
org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:556)
at java.lang.Thread.run(Thread.java:619)

Re: fatalIOException: Connection Reset

Posted by Oleg Kalnichevski <ol...@apache.org>.
Adrian Cole wrote:
> I have a project: jclouds which uses the following version of httpnio:
>         <dependency>
>             <groupId>org.apache.httpcomponents</groupId>
>             <artifactId>httpcore-nio</artifactId>
>             <version>4.0</version>
>         </dependency>
> 
> I have a connection
> pool<http://code.google.com/p/jclouds/source/browse/trunk/extensions/httpnio/src/main/java/org/jclouds/http/httpnio/pool/HttpNioFutureCommandConnectionPool.java>
> which
> implements EventListener<http://hc.apache.org/httpcomponents-core/httpcore-nio/apidocs/org/apache/http/nio/protocol/EventListener.html#fatalIOException(java.io.IOException,%20org.apache.http.nio.NHttpConnection)>.
>  Now, this application is mainly used to connect to Amazon S3.  I often get
> IOExceptions like below for connection reset by peer.  However, they are
> coming in as fatalIOException. 

EventListener#fatalIOException is somewhat a misnomer. The exceptions 
passed to the event listener are not fatal for the I/O reactor. However, 
the connection that caused that I/O exception is indeed considered 
invalid and gets shut down.


  This seems to imply a complete shutdown of
> the IOReactor. 

That should not be the case.

  My first impression is this is too severe, as re-creating an
> IOReactor over a connection reset seems a bit harsh.  However this is the
> current behaviour.  Do you have any ideas on how I can work around
> connection resets in a simple way?
> 

The I/O reactor should remain perfectly functional in case just a 
individual connection caused an I/O exception. The connection will get 
shut down but the I/O reactor itself should still be in a consistent 
state and very much functional. If the I/O reactor ever encounters an 
exception it deems non-recoverable it will automatically shut down itself.

Hope this helps.

Oleg


> Best regards,
> 
> Adrian Cole
> 
> Here are some details:
> 
> http://code.google.com/p/jclouds/issues/detail?id=14
> 
> SEVERE: [closed]-31222126{s3.amazonaws.com/72.21.202.112:80} - io error
> java.io.IOException: Connection reset by peer
> at sun.nio.ch.FileDispatcher.read0(Native Method)
> at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:21)
> at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:233)
> at sun.nio.ch.IOUtil.read(IOUtil.java:206)
> at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:236)
> at
> org.apache.http.impl.nio.reactor.SessionInputBufferImpl.fill(SessionInputBufferImpl.java:94)
> at
> org.apache.http.impl.nio.codecs.AbstractMessageParser.fillBuffer(AbstractMessageParser.java:127)
> at
> org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:156)
> at
> org.apache.http.impl.nio.DefaultClientIOEventDispatch.inputReady(DefaultClientIOEventDispatch.java:146)
> at
> org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:153)
> at
> org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:314)
> at
> org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:294)
> at
> org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:256)
> at
> org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:96)
> at
> org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:556)
> at java.lang.Thread.run(Thread.java:619)
> 


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


Re: fatalIOException: Connection Reset

Posted by Adrian Cole <ad...@gmail.com>.
Thanks for the advise on this.  It works well.
-Adrian

On Sun, May 3, 2009 at 12:14 AM, Adrian Cole <ad...@gmail.com>wrote:

> I have a project: jclouds which uses the following version of httpnio:
>         <dependency>
>             <groupId>org.apache.httpcomponents</groupId>
>             <artifactId>httpcore-nio</artifactId>
>             <version>4.0</version>
>         </dependency>
>
> I have a connection pool<http://code.google.com/p/jclouds/source/browse/trunk/extensions/httpnio/src/main/java/org/jclouds/http/httpnio/pool/HttpNioFutureCommandConnectionPool.java> which
> implements EventListener<http://hc.apache.org/httpcomponents-core/httpcore-nio/apidocs/org/apache/http/nio/protocol/EventListener.html#fatalIOException(java.io.IOException,%20org.apache.http.nio.NHttpConnection)>.
>  Now, this application is mainly used to connect to Amazon S3.  I often get
> IOExceptions like below for connection reset by peer.  However, they are
> coming in as fatalIOException.  This seems to imply a complete shutdown of
> the IOReactor.  My first impression is this is too severe, as re-creating an
> IOReactor over a connection reset seems a bit harsh.  However this is the
> current behaviour.  Do you have any ideas on how I can work around
> connection resets in a simple way?
>
> Best regards,
>
> Adrian Cole
>
> Here are some details:
>
> http://code.google.com/p/jclouds/issues/detail?id=14
>
> SEVERE: [closed]-31222126{s3.amazonaws.com/72.21.202.112:80} - io error
> java.io.IOException: Connection reset by peer
>  at sun.nio.ch.FileDispatcher.read0(Native Method)
> at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:21)
>  at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:233)
> at sun.nio.ch.IOUtil.read(IOUtil.java:206)
>  at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:236)
> at
> org.apache.http.impl.nio.reactor.SessionInputBufferImpl.fill(SessionInputBufferImpl.java:94)
>  at
> org.apache.http.impl.nio.codecs.AbstractMessageParser.fillBuffer(AbstractMessageParser.java:127)
> at
> org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:156)
>  at
> org.apache.http.impl.nio.DefaultClientIOEventDispatch.inputReady(DefaultClientIOEventDispatch.java:146)
> at
> org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:153)
>  at
> org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:314)
> at
> org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:294)
>  at
> org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:256)
> at
> org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:96)
>  at
> org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:556)
> at java.lang.Thread.run(Thread.java:619)
>
>