OkHttp
ライブラリでは、アプリケーションはSocketTimeoutException
の問題に直面しています。要求サイズが小さければ、それは正常に動作しています(1MB未満)。 10秒以内にこの例外が発生しています。ソケットタイムアウト(readTimeout
)の値がさらに高いです。一貫して要求に失敗しています(サイズは1.8MBです)。 HttpUrlConnection
でリクエストを実行したときに正常に動作しています。失敗の理由は何でしょうか?java.net.SocketTimeoutException:タイムアウト
03-29 12:16:38.997 32066-4018/com.mobile W/System.err: java.net.SocketTimeoutException: timeout
03-29 12:16:38.997 32066-4018/com.mobile W/System.err: at okio.Okio$3.newTimeoutException(Okio.java:207)
03-29 12:16:38.997 32066-4018/com.mobile W/System.err: at okio.AsyncTimeout.exit(AsyncTimeout.java:261)
03-29 12:16:38.997 32066-4018/com.mobile W/System.err: at okio.AsyncTimeout$1.write(AsyncTimeout.java:158)
03-29 12:16:38.997 32066-4018/com.mobile W/System.err: at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:176)
03-29 12:16:38.997 32066-4018/com.mobile W/System.err: at okio.RealBufferedSink.write(RealBufferedSink.java:46)
03-29 12:16:38.997 32066-4018/com.mobile W/System.err: at okhttp3.internal.http.Http1xStream$FixedLengthSink.write(Http1xStream.java:286)
03-29 12:16:38.997 32066-4018/com.mobile W/System.err: at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:176)
03-29 12:16:38.997 32066-4018/com.mobile W/System.err: at okio.RealBufferedSink.write(RealBufferedSink.java:96)
03-29 12:16:38.997 32066-4018/com.mobile W/System.err: at okhttp3.RequestBody$2.writeTo(RequestBody.java:96)
03-29 12:16:38.997 32066-4018/com.mobile W/System.err: at okhttp3.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:704)
03-29 12:16:38.997 32066-4018/com.mobile W/System.err: at okhttp3.internal.http.HttpEngine.readResponse(HttpEngine.java:563)
03-29 12:16:38.997 32066-4018/com.mobile W/System.err: at okhttp3.RealCall.getResponse(RealCall.java:241)
03-29 12:16:38.997 32066-4018/com.mobile W/System.err: at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:198)
03-29 12:16:38.998 32066-4018/com.mobile W/System.err: at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:160)
03-29 12:16:38.998 32066-4018/com.mobile W/System.err: at okhttp3.RealCall.execute(RealCall.java:57)
03-29 12:16:38.998 32066-4018/com.mobile W/System.err: at com.mobizio.api.BaseApi.sendOkHttpRequest(BaseApi.java:81)
03-29 12:16:38.998 32066-4018/com.mobile W/System.err: at com.mobizio.api.BaseApi.doInBackground(BaseApi.java:45)
03-29 12:16:38.998 32066-4018/com.mobile W/System.err: at com.mobizio.api.BaseApi.doInBackground(BaseApi.java:30)
03-29 12:16:38.998 32066-4018/com.mobile W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:292)
03-29 12:16:38.998 32066-4018/com.mobile W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
03-29 12:16:38.998 32066-4018/com.mobile W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
03-29 12:16:38.998 32066-4018/com.mobile W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
03-29 12:16:38.998 32066-4018/com.mobile W/System.err: at java.lang.Thread.run(Thread.java:818)
03-29 12:16:38.998 32066-4018/com.mobile W/System.err: Caused by: java.net.SocketException: socket is closed
03-29 12:16:38.998 32066-4018/com.mobile W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl$SSLOutputStream.write(OpenSSLSocketImpl.java:759)
03-29 12:16:38.998 32066-4018/com.mobile W/System.err: at okio.Okio$1.write(Okio.java:80)
03-29 12:16:38.998 32066-4018/com.mobile W/System.err: at okio.AsyncTimeout$1.write(AsyncTimeout.java:155)
03-29 12:16:38.998 32066-4018/com.mobile W/System.err: ... 20 more
あなたのクライアント値をより大きな読み出し時間を与えます。ストリームがソケットから読み込まれるときにタイムアウトが発生しているようです。 –
@NikolaDespotoski私は既にこの問題に直面していますが、ソケットタイムアウトを15分に設定しました。 – Vivek