question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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!

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
dtolstyicommented, May 31, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

ktor-network - client socket close throws exception on server ...
If a client connects and at some point the connection is closed by the client, an IOException is thrown, and caught, but the...
Read more >
How to close connection just after getting Long Polling request ...
So I would like the algorithm to work like this: 1) Server get a long polling request. 2) If there is a data...
Read more >
asyncio vs Ktor | What are the differences? - StackShare
What is Ktor? It is a framework for building asynchronous servers and clients in connected systems using the Kotlin programming language. Ktor Stats....
Read more >
[FIXED] Getting Exceptions while running a Spring boot app ...
ConnectionClosedException : Connection is closed; nested exception is ElasticsearchException[java.util.concurrent.
Read more >
Framework for quickly creating connected ... - AndroidRepo
If you find a security vulnerability in Ktor, we kindly request that you reach out to ... is closed for a long polling...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found