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.

java.net.SocketTimeoutException with no lines referencing my code

See original GitHub issue

Ktor Version and Engine Used (client or server and name)

  • io.ktor:ktor-client-core:1.2.3-rc
  • io.ktor:ktor-client-core-jvm:1.2.3-rc
  • io.ktor:ktor-client-okhttp:1.2.3-rc

Describe the bug See the exception below. This exception is reported by Firebase. I can not reproduce it myself although quite some users appear to get this bug. I have no idea where this happens in my code and that is why I am unable to fix it myself. It looks like some sort of timeout error.

Fatal Exception: java.net.SocketTimeoutException: timeout
       at okio.SocketAsyncTimeout.newTimeoutException + 159(SocketAsyncTimeout.java:159)
       at okio.AsyncTimeout.exit$jvm + 203(AsyncTimeout.java:203)
       at okio.AsyncTimeout$source$1.read + 163(AsyncTimeout.java:163)
       at okio.RealBufferedSource.read + 41(RealBufferedSource.java:41)
       at okhttp3.internal.http1.Http1ExchangeCodec$AbstractSource.read + 352(Http1ExchangeCodec.java:352)
       at okhttp3.internal.http1.Http1ExchangeCodec$UnknownLengthSource.read + 488(Http1ExchangeCodec.java:488)
       at okhttp3.internal.connection.Exchange$ResponseBodySource.read + 279(Exchange.java:279)
       at okio.RealBufferedSource.read + 41(RealBufferedSource.java:41)
       at okhttp3.internal.cache.CacheInterceptor$cacheWritingResponse$cacheWritingSource$1.read + 158(CacheInterceptor.java:158)
       at okio.RealBufferedSource.read + 148(RealBufferedSource.java:148)
       at io.ktor.client.engine.okhttp.OkHttpEngineKt$toChannel$1$1$1.invoke + 97(OkHttpEngineKt.java:97)
       at io.ktor.client.engine.okhttp.OkHttpEngineKt$toChannel$1$1$1.invoke(OkHttpEngineKt.java:1)
       at kotlinx.coroutines.io.ByteBufferChannel.write + 1508(ByteBufferChannel.java:1508)
       at kotlinx.coroutines.io.ByteWriteChannel$DefaultImpls.write$default + 84(ByteWriteChannel.java:84)
       at io.ktor.client.engine.okhttp.OkHttpEngineKt$toChannel$1.invokeSuspend + 96(OkHttpEngineKt.java:96)
       at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith + 33(BaseContinuationImpl.java:33)
       at kotlinx.coroutines.DispatchedTask.run + 241(DispatchedTask.java:241)
       at java.util.concurrent.ThreadPoolExecutor.runWorker + 1167(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run + 641(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run + 764(Thread.java:764)
Caused by java.net.SocketTimeoutException: Read timed out
       at java.net.SocketInputStream.socketRead0(SocketInputStream.java)
       at java.net.SocketInputStream.socketRead + 119(SocketInputStream.java:119)
       at java.net.SocketInputStream.read + 176(SocketInputStream.java:176)
       at java.net.SocketInputStream.read + 144(SocketInputStream.java:144)
       at okio.InputStreamSource.read + 102(InputStreamSource.java:102)
       at okio.AsyncTimeout$source$1.read + 159(AsyncTimeout.java:159)
       at okio.RealBufferedSource.read + 41(RealBufferedSource.java:41)
       at okhttp3.internal.http1.Http1ExchangeCodec$AbstractSource.read + 352(Http1ExchangeCodec.java:352)
       at okhttp3.internal.http1.Http1ExchangeCodec$UnknownLengthSource.read + 488(Http1ExchangeCodec.java:488)
       at okhttp3.internal.connection.Exchange$ResponseBodySource.read + 279(Exchange.java:279)
       at okio.RealBufferedSource.read + 41(RealBufferedSource.java:41)
       at okhttp3.internal.cache.CacheInterceptor$cacheWritingResponse$cacheWritingSource$1.read + 158(CacheInterceptor.java:158)
       at okio.RealBufferedSource.read + 148(RealBufferedSource.java:148)
       at io.ktor.client.engine.okhttp.OkHttpEngineKt$toChannel$1$1$1.invoke + 97(OkHttpEngineKt.java:97)
       at io.ktor.client.engine.okhttp.OkHttpEngineKt$toChannel$1$1$1.invoke(OkHttpEngineKt.java:1)
       at kotlinx.coroutines.io.ByteBufferChannel.write + 1508(ByteBufferChannel.java:1508)
       at kotlinx.coroutines.io.ByteWriteChannel$DefaultImpls.write$default + 84(ByteWriteChannel.java:84)
       at io.ktor.client.engine.okhttp.OkHttpEngineKt$toChannel$1.invokeSuspend + 96(OkHttpEngineKt.java:96)
       at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith + 33(BaseContinuationImpl.java:33)
       at kotlinx.coroutines.DispatchedTask.run + 241(DispatchedTask.java:241)
       at java.util.concurrent.ThreadPoolExecutor.runWorker + 1167(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run + 641(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run + 764(Thread.java:764)

To Reproduce As the stacktrace shows no lines of my code I do not know how to reproduce it. I would really appreciate some help for this exception. I am not entirely sure if this is related to Ktor, but thought this would be the best place to report it. I have Kotlin Coroutines debug mode enabled as well.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:8
  • Comments:21 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
willinwucommented, Dec 19, 2019

We are also experiencing a similar problem (using 1.2.5):

java.net.SocketTimeoutException: 10,000 milliseconds timeout on connection http-outgoing-9 [ACTIVE]
	at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.timeout(HttpAsyncRequestExecutor.java:387)
	at org.apache.http.impl.nio.client.InternalIODispatch.onTimeout(InternalIODispatch.java:92)
	at org.apache.http.impl.nio.client.InternalIODispatch.onTimeout(InternalIODispatch.java:39)
	at org.apache.http.impl.nio.reactor.AbstractIODispatch.timeout(AbstractIODispatch.java:175)
	at org.apache.http.impl.nio.reactor.BaseIOReactor.sessionTimedOut(BaseIOReactor.java:263)
	at org.apache.http.impl.nio.reactor.AbstractIOReactor.timeoutCheck(AbstractIOReactor.java:492)
	at org.apache.http.impl.nio.reactor.BaseIOReactor.validate(BaseIOReactor.java:213)
	at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:280)
	at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104)
	at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:591)
	at java.lang.Thread.run(Thread.java:748)`

2reactions
luqasncommented, Sep 27, 2019

I wrote a repro case using the current prerelease version 1.3-beta1 (1.2 has the same issue). Not using SocketTimeoutException but ConnectionRefused because it is easier to cause, but behaviour should be the same: https://github.com/luqasn/ktor-httpclient-exception-repro

Read more comments on GitHub >

github_iconTop Results From Across the Web

java.net.SocketTimeoutException with no lines referencing ...
I have no idea where this happens in my code and that is why I am unable to fix it myself. It looks...
Read more >
android - java.net.SocketTimeoutException: timeout
I am getting this exception within 10 seconds, even my socket timeout( readTimeout ) value is much higher. It is consistently failing for...
Read more >
How to resolve java.net.SocketTimeoutException
Your Java socket is timing out means that it takes too long to get respond from other device and your request expires before...
Read more >
'Read timed out', seen during SyncNode request
Issuing a syncNode request from the node (nodehost.domain.com) such as, > syncNode.sh ... msg=Read timed out; targetException=java.net.
Read more >
Known Issues for JDK 8
If there are network connection problems, such as when a proxy is turned off, the revocation check can take a long time, before...
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