能否帮忙分析下抛出这个的原因,代码如下:
09-22 17:35:59.644 20596-20596/com.android W/System.err: java.net.SocketTimeoutException: timeout
09-22 17:35:59.649 20596-20596/com.android W/System.err: at okio.Okio$3.newTimeoutException(Okio.java:212)
09-22 17:35:59.649 20596-20596/com.android W/System.err: at okio.AsyncTimeout.exit(AsyncTimeout.java:277)
09-22 17:35:59.649 20596-20596/com.android W/System.err: at okio.AsyncTimeout$2.read(AsyncTimeout.java:244)
09-22 17:35:59.649 20596-20596/com.android W/System.err: at okio.RealBufferedSource.read(RealBufferedSource.java:45)
09-22 17:35:59.649 20596-20596/com.android W/System.err: at okhttp3.internal.http.Http1xStream$FixedLengthSource.read(Http1xStream.java:381)
09-22 17:35:59.650 20596-20596/com.android W/System.err: at okio.RealBufferedSource.read(RealBufferedSource.java:45)
09-22 17:35:59.650 20596-20596/com.android W/System.err: at okio.ForwardingSource.read(ForwardingSource.java:35)
09-22 17:35:59.650 20596-20596/com.android W/System.err: at retrofit2.OkHttpCall$ExceptionCatchingRequestBody$1.read(OkHttpCall.java:279)
09-22 17:35:59.650 20596-20596/com.android W/System.err: at okio.RealBufferedSource.request(RealBufferedSource.java:66)
09-22 17:35:59.650 20596-20596/com.android W/System.err: at com.squareup.moshi.BufferedSourceJsonReader.nextNonWhitespace
(BufferedSourceJsonReader.java:933)
09-22 17:35:59.650 20596-20596/com.android W/System.err: at com.squareup.moshi.BufferedSourceJsonReader.doPeek
(BufferedSourceJsonReader.java:327)
09-22 17:35:59.650 20596-20596/com.android W/System.err: at com.squareup.moshi.BufferedSourceJsonReader.peek
(BufferedSourceJsonReader.java:202)
09-22 17:35:59.650 20596-20596/com.android W/System.err: at com.squareup.moshi.JsonAdapter$1.fromJson(JsonAdapter.java:65)
09-22 17:35:59.651 20596-20596/com.android W/System.err: at com.squareup.moshi.JsonAdapter.fromJson(JsonAdapter.java:33)
09-22 17:35:59.651 20596-20596/com.android W/System.err: at retrofit2.MoshiResponseBodyConverter.convert(MoshiResponseBodyConverter.java:33)
09-22 17:35:59.651 20596-20596/com.android W/System.err: at retrofit2.MoshiResponseBodyConverter.convert(MoshiResponseBodyConverter.java:23)
09-22 17:35:59.651 20596-20596/com.android W/System.err: at retrofit2.ServiceMethod.toResponse(ServiceMethod.java:117)
09-22 17:35:59.651 20596-20596/com.android W/System.err: at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:211)
09-22 17:35:59.651 20596-20596/com.android W/System.err: at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:106)
09-22 17:35:59.651 20596-20596/com.android W/System.err: at okhttp3.RealCall$AsyncCall.execute(RealCall.java:133)
09-22 17:35:59.652 20596-20596/com.android W/System.err: at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
09-22 17:35:59.652 20596-20596/com.android W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
09-22 17:35:59.652 20596-20596/com.android W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
09-22 17:35:59.652 20596-20596/com.android W/System.err: at java.lang.Thread.run(Thread.java:818)
伺服器請求超時了吧
有可能是真的連接超時,有兩種方案來測試一下
1:把HttpConnectionTimeOut時間設定的長一點,比如一分鐘
2:可以使用一些接口調用工具(Chrome瀏覽器的Postman插件)進行接口的測試,看一下呼叫結果,如果呼叫正常,就再分析看看是不是自己程式碼的問題