ktor: ktor connection is closed for a long polling requests (ConnectionClosedException)

Ktor Version

1.1.3

Ktor Engine Used(client or server and name)

Apache Client

JVM Version, Operating System and Relevant Context

1.8

Feedback

I’m coming to this issue here after I initially thought that the problem is in underlying client (AsyncHttpClient): https://issues.apache.org/jira/browse/HTTPCLIENT-1980

After many investigations it looks like the problem is not in AsyncHttpClient but in ktor. I’ve made a small reproducers that just perform constant GET requests to the same URL every 5 seconds. These reproducers were done using: HttpClient, AsyncHttpClient, Netty, vert.x Web Client and ktor. All clients except ktor are working fine for multiple days (~4 days). Whereas ktor is stopping after some hours with ConnectionClosedException:

Exception in thread "main" org.apache.http.ConnectionClosedException: Connection closed
        at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.endOfInput(HttpAsyncRequestExecutor.java:345)
        at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:261)
        at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:81)
        at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:39)
        at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:121)
        at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:162)
        at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:337)
        at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:315)
        at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:276)
        at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104)
        at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:588)
        at java.lang.Thread.run(Thread.java:748)

Do you need any logs to be done or how can I help you to find the cause?

Thank you!

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 40 (13 by maintainers)

Most upvoted comments

Hi Leonid @e5l. Are there any news regarding the issue or possible milestones when it can be fixed? Thank you.