okhttp 2.7.5 +改装1.9.0中的java.net.SocketTimeoutException主要在蜂窝网络(4G / 3G / 2G)连接中

时间:2019-01-14 10:44:24

标签: android okhttp

我尝试使用

OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(1, TimeUnit.MINUTES); // connect timeout
client.setReadTimeout(1, TimeUnit.MINUTES);
client.setWriteTimeout(1, TimeUnit.MINUTES);
client.setConnectionPool(new ConnectionPool(0, 1,
TimeUnit.NANOSECONDS))

还在清单中添加了android:vmSafeMode =“ true”。但是问题仍然存在,这是okHttp或改造的问题吗?请分享您的想法。将超时增加到5分钟也是很好的选择。

I/REST-LOG: java.net.SocketTimeoutException: timeout
at com.squareup.okhttp.internal.framed.FramedStream$StreamTimeout.newTimeou    tException(FramedStream.java:605)
at com.squareup.okhttp.internal.framed.FramedStream$StreamTimeout.exitAndTh    rowIfTimedOut(FramedStream.java:613)
at com.squareup.okhttp.internal.framed.FramedStream.getResponseHeaders(Fram    edStream.java:143)
at com.squareup.okhttp.internal.http.Http2xStream.readResponseHeaders(Http2    xStream.java:150)
at com.squareup.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEng    ine.java:737)
at com.squareup.okhttp.internal.http.HttpEngine.access$200(HttpEngine.java:    87)
at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.pro    ceed(HttpEngine.java:722)
at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.jav    a:576)
at com.squareup.okhttp.Call.getResponse(Call.java:287)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:2    43)
at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:205)
at com.squareup.okhttp.Call.execute(Call.java:80)
at retrofit.client.OkClient.execute(OkClient.java:53)
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:326)
at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240)
at java.lang.reflect.Proxy.invoke(Proxy.java:397)
at $Proxy16.sendPosition(Unknown Source)

0 个答案:

没有答案