square / okhttp

Square’s meticulous HTTP client for the JVM, Android, and GraalVM.
https://square.github.io/okhttp/
Apache License 2.0
45.87k stars 9.16k forks source link

socket timeout #3195

Closed dinuscxj closed 7 years ago

dinuscxj commented 7 years ago

02-28 21:38:42.349 31577-1880/com.kwai.mercury W/System.err: java.net.SocketTimeoutException: timeout 02-28 21:38:42.349 31577-1880/com.kwai.mercury W/System.err: at okio.Okio$3.newTimeoutException(Okio.java:207) 02-28 21:38:42.349 31577-1880/com.kwai.mercury W/System.err: at okio.AsyncTimeout.exit(AsyncTimeout.java:261) 02-28 21:38:42.349 31577-1880/com.kwai.mercury W/System.err: at okio.AsyncTimeout$1.write(AsyncTimeout.java:158) 02-28 21:38:42.349 31577-1880/com.kwai.mercury W/System.err: at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:176) 02-28 21:38:42.349 31577-1880/com.kwai.mercury W/System.err: at okio.RealBufferedSink.write(RealBufferedSink.java:46) 02-28 21:38:42.349 31577-1880/com.kwai.mercury W/System.err: at com.squareup.okhttp.internal.http.RetryableSink.writeToSocket(RetryableSink.java:78) 02-28 21:38:42.349 31577-1880/com.kwai.mercury W/System.err: at com.squareup.okhttp.internal.http.HttpConnection.writeRequestBody(HttpConnection.java:240) 02-28 21:38:42.349 31577-1880/com.kwai.mercury W/System.err: at com.squareup.okhttp.internal.http.HttpTransport.writeRequestBody(HttpTransport.java:56) 02-28 21:38:42.350 31577-1880/com.kwai.mercury W/System.err: at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:777)

JakeWharton commented 7 years ago

Socket timeouts are normal occurrences. What leads you to believe that this is a bug?

On Tue, Feb 28, 2017, 11:03 PM dinus_developer notifications@github.com wrote:

02-28 21:38:42.349 31577-1880/com.kwai.mercury W/System.err: java.net.SocketTimeoutException: timeout 02-28 21:38:42.349 31577-1880/com.kwai.mercury W/System.err: at okio.Okio$3.newTimeoutException(Okio.java:207) 02-28 21:38:42.349 31577-1880/com.kwai.mercury W/System.err: at okio.AsyncTimeout.exit(AsyncTimeout.java:261) 02-28 21:38:42.349 31577-1880/com.kwai.mercury W/System.err: at okio.AsyncTimeout$1.write(AsyncTimeout.java:158) 02-28 21:38:42.349 31577-1880/com.kwai.mercury W/System.err: at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:176) 02-28 21:38:42.349 31577-1880/com.kwai.mercury W/System.err: at okio.RealBufferedSink.write(RealBufferedSink.java:46) 02-28 21:38:42.349 31577-1880/com.kwai.mercury W/System.err: at com.squareup.okhttp.internal.http.RetryableSink.writeToSocket(RetryableSink.java:78) 02-28 21:38:42.349 31577-1880/com.kwai.mercury W/System.err: at com.squareup.okhttp.internal.http.HttpConnection.writeRequestBody(HttpConnection.java:240) 02-28 21:38:42.349 31577-1880/com.kwai.mercury W/System.err: at com.squareup.okhttp.internal.http.HttpTransport.writeRequestBody(HttpTransport.java:56) 02-28 21:38:42.350 31577-1880/com.kwai.mercury W/System.err: at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:777)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/square/okhttp/issues/3195, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEEbJPZpaxTGEEDtEmxVM1AB8ihJvsks5rhO4XgaJpZM4MPMhg .

liuxj commented 7 years ago

How to catch Socket timeout exception?

liuxj commented 7 years ago

I use getInstance(context).client.newCall(request).enqueue(, how to catch the SocketTimeoutExceptions?

JakeWharton commented 7 years ago

You don't need to catch it. It will be passed to onFailure.

On Thu, Mar 2, 2017 at 2:00 AM xiangjun notifications@github.com wrote:

I use getInstance(context).client.newCall(request).enqueue(, how to catch the SocketTimeoutExceptions?

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/square/okhttp/issues/3195#issuecomment-283573169, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEEULCMYbvPICqfPrwUqMV2-PuGXkoks5rhmkJgaJpZM4MPMhg .

liuxj commented 7 years ago

Oh, thanks

swankjesse commented 7 years ago

No action to take on this.