您的位置:首页 > 理论基础 > 计算机网络

okhttp的坑坑坑 unexpected end of stream on Connection

2017-07-19 11:10 881 查看
之前okhttp用着没问题  很爽  突然不知道改了那  就一直报这个错误  

 W/System.err: java.io.IOException: unexpected end of stream on Connection{app.zhicall.cn:443, proxy=DIRECT@ hostAddress=app.zhicall.cn/101.37.43.190:443 cipherSuite=T

 W/System.err:     at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:205)

 W/System.err:     at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:75)

 W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)

 W/System.err:     at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)

 W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)

 W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)

 W/System.err:     at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)

 W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)

 W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)

 W/System.err:     at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)

 W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)

 W/System.err:     at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)

 W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)

 W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)

 W/System.err:     at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185)

 W/System.err:     at okhttp3.RealCall$AsyncCall.execute(RealCall.java:135)

 W/System.err:     at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)

 W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)

 W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)

 W/System.err:     at java.lang.Thread.run(Thread.java:818)

 W/System.err: Caused by: java.io.EOFException: \n not found: limit=0 content=…

 W/System.err:     at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:227)

 W/System.err:     at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:211)

 W/System.err:     at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:189)

 W/System.err: ... 19 more

然后各种百度 google

给出的答案大部分都是

.header("Connection","close")

但是没解决我的问题  

最后找到了一个方法  如下

解决连接

OkHttpClient client = new OkHttpClient.Builder()
.retryOnConnectionFailure(true)
.build();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Android okhttp