相关文章推荐
胆小的单杠  ·  Spark source ...·  2 年前    · 

java.io.EOFException。\not found: limit=0 content=...

2 人关注

我想连接到webSocket,但出现了一个错误。如何解决这个问题?或者可能是服务器端的错误?

implementation 'com.squareup.okhttp3:okhttp:3.9.1'

Code:

final Request request = new Request.Builder()
            .get()
            .url("http://develop.by:8000")
           .build();
OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .readTimeout(30, TimeUnit.SECONDS)
                .writeTimeout(30, TimeUnit.SECONDS)
                .build();
WebSocket webSocket = okHttpClient.newWebSocket(request, new WebSocketListener() {...}

Error:

java.io.IOException: unexpected end of stream on Connection{develop.by:8000, proxy=DIRECT@ hostAddress=develop.by/195.***.***.**:8000 cipherSuite=none protocol=http/1.1}
at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:205)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:125)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:147)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.io.EOFException: \n not found: limit=0 content=…
    at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:227)
    at okhttp3.internal.http1.Http1Codec.readHeaderLine(Http1Codec.java:212)
    at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:189)
    ... 19 more
    
3 个评论
@Tigo2018仍不明白如何解决我这边的问题。
你是否尝试过.retryOnConnectionFailure(true)?
java
android
okhttp
NickUnuchek
NickUnuchek
发布于 2018-02-15
2 个回答
EL TEGANI MOHAMED HAMAD GABIR
EL TEGANI MOHAMED HAMAD GABIR
发布于 2019-09-05
已采纳
0 人赞同

根据 this 问题 禁用gzip