On Wed, Nov 22, 2017 at 9:19 PM, Nitu Choudhary
<[email protected]>
wrote:
Hi,
Under high concurrency we see cases where I/O reactor is getting
terminated
when closing the input stream. In our application we also close
the input
stream as we want to cleanup the memory under various exception
conditions.
What is the recommended way to consume the http entity? It shows
that on
timeout the nio client is trying to consume the entity, but it has
already
been consumed by our application as it got a done signal, and we
retrieved
the entity and closed it.
Hi Nitu
Unlike its blocking counterpart HttpAsyncClient automatically
deallocates
resources once a message exchange is complete (successfully or
unsuccessfully). One does not need to ensure the response entity is
fully
consumed in order to ensure proper deallocation of the connection
associated with it. This is taken care of by the framework.
However I would strongly recommend to avoid mixing non-blocking I/O
with
inherently blocking InputStream / OutputStream based APIs. I would
recommend using proper non-blocking HttpAsyncRequestProducer and
HttpAsyncResponseConsumer implementations for any non-trivial
request /
response exchanges with HttpAsyncClient. In other words try getting
rid of
SequenceInputStream entirely.
Hope this helps
Oleg
Here is the stack for your reference:
org.apache.http.impl.nio.client.InternalHttpAsyncClient - I/O
reactor
terminated abnormally java.util.NoSuchElementException: null at
java.util.
ArrayList$Itr.next(ArrayList.java:854) at
java.util.Collections$3.nextEl
ement(Collections.java:5216) at
java.io.SequenceInputStream.nextStream(
SequenceInputStream.java:110) at java.io.SequenceInputStream.close(
SequenceInputStream.java:232) at org.apache.http.nio.entity.Ent
ityAsyncContentProducer.close(EntityAsyncContentProducer.java:92)
at org.
apache.http.nio.protocol.BasicAsyncRequestProducer.close(
BasicAsyncRequestProducer.java:155) at
org.apache.http.impl.nio.client.
DefaultClientExchangeHandlerImpl.releaseResources(DefaultC
lientExchangeHandlerImpl.java:84) at
org.apache.http.impl.nio.client.
AbstractClientExchangeHandler.failed(AbstractClientExchangeH
andler.java:429)
at org.apache.http.impl.nio.client.AbstractClientExchangeHandler.
connectionRequestFailed(AbstractClientExchangeHandler.java:348) at
org.
apache.http.impl.nio.client.AbstractClientExchangeHandler.access$100(
AbstractClientExchangeHandler.java:62) at
org.apache.http.impl.nio.clien
t.
AbstractClientExchangeHandler$1.failed(AbstractClientExchang
eHandler.java:
392) at org.apache.http.concurrent.BasicFuture.failed(BasicFuture.
java:134)
at
org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager$1.
failed(PoolingNHttpClientConnectionManager.java:289) at
org.apache.http.
concurrent.BasicFuture.failed(BasicFuture.java:134) at
org.apache.http.nio.
pool.RouteSpecificPool.timeout(RouteSpecificPool.java:168) at
org.apache.
http.nio.pool.AbstractNIOConnPool.requestTimeout(AbstractNIO
ConnPool.java:
584) at
org.apache.http.nio.pool.AbstractNIOConnPool$InternalSession
RequestCallback.timeout(AbstractNIOConnPool.java:851) at
org.apache.http.
impl.nio.reactor.SessionRequestImpl.timeout(SessionRequestImpl.java:183)
at
org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.
processTimeouts(
DefaultConnectingIOReactor.java:210) at
org.apache.http.impl.nio.reactor.
DefaultConnectingIOReactor.processEvents(DefaultConnectingIO
Reactor.java:155)
at
org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(
AbstractMultiworkerIOReactor.java:348) at
org.apache.http.impl.nio.conn.
PoolingNHttpClientConnectionManager.execute(PoolingNHttpClie
ntConnectionManager.java:194) at org.apache.http.impl.nio.client.
CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64)
at
java.lang.Thread.run(Thread.java:748)
regards,
nitu
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]