okhttp3:unexpected end of stream on Connection

转载自:okhttp的坑坑坑 unexpected end of stream on Connection_suwenlai的博客-CSDN博客

叙述

之前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
————————————————
版权声明:本文为CSDN博主「suwenlai」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/suwenlai/article/details/75349539

解决方案

OkHttpClient client = new OkHttpClient.Builder()
        .retryOnConnectionFailure(true)
        .build();

开启异常重试机制,连接错误会再次尝试,直到成功。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值