OKHttp Причина: java.io.EOFException: \ n не найден: limit = 0 content =… - PullRequest
0 голосов
/ 23 декабря 2018

Я иногда сталкивался с этой проблемой, мой сайт НЕ сталкивался с этой проблемой до сегодняшнего дня. Когда я сталкиваюсь с этой проблемой, я пытаюсь ее решить, проверяя мой код и отслеживая журнал проблем, даже пытаясь переполнить стек , ответчик может отображать список:

  1. установить retryOnConnectionFailure (true) при создании экземпляра OkHttpClient.
  2. установить заголовок («Соединение», «закрыть»)
  3. установить заголовок («Accept-Encoding», «identity»)

Но ни один из них не мог решить мою проблему, я также пытаюсь использовать addNetworkInterceptor вместо addInterceptor, он НЕ работаетхотя.

Наконец, я пытаюсь вернуться к предыдущей версии.Ну, мой предыдущий код выглядит следующим образом:

response.setStatusCode(HttpStatus.UNAUTHORIZED);
return Mono.empty();

, а теперь:

response.setStatusCode(HttpStatus.UNAUTHORIZED);
return response.writeAndFlushWith(Flux.just(Flux.fromStream(
                    Stream.generate(() -> ASRUtil.buildNLUResponse(ResponseEnum.TOKEN_NOT_EXIST))
                            .limit(1)
                            .map(ASRUtil::convertNLU2DataBuffer)
)));

Я использую приведенный выше код, просто хочу напомнить клиентам о том, что их токены недействительны или НЕ существуют.Но, похоже, это вызывает проблему.

Любые предложения приветствуются.

Вложение журнала:

java.io.IOException: unexpected end of stream on Connection{127.0.0.1:9443, proxy=DIRECT hostAddress=/127.0.0.1:9443 cipherSuite=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA protocol=http/1.1}
    at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:208) ~[okhttp-3.11.0.jar:na]
    at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88) ~[okhttp-3.11.0.jar:na]
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) ~[okhttp-3.11.0.jar:na]
    at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45) ~[okhttp-3.11.0.jar:na]
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) ~[okhttp-3.11.0.jar:na]
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) ~[okhttp-3.11.0.jar:na]
    at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93) ~[okhttp-3.11.0.jar:na]
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) ~[okhttp-3.11.0.jar:na]
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) ~[okhttp-3.11.0.jar:na]
    at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) ~[okhttp-3.11.0.jar:na]
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) ~[okhttp-3.11.0.jar:na]
    at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126) ~[okhttp-3.11.0.jar:na]
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) ~[okhttp-3.11.0.jar:na]
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) ~[okhttp-3.11.0.jar:na]
    at com.asr.client.service.WebService.lambda$handlePostASR$3(WebService.java:263) ~[classes/:na]
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) ~[okhttp-3.11.0.jar:na]
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) ~[okhttp-3.11.0.jar:na]
    at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200) ~[okhttp-3.11.0.jar:na]
    at okhttp3.RealCall$AsyncCall.execute(RealCall.java:147) ~[okhttp-3.11.0.jar:na]
    at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) [okhttp-3.11.0.jar:na]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_191]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_191]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_191]
Caused by: java.io.EOFException: \n not found: limit=0 content=…
    at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:237) ~[okio-1.14.0.jar:na]
    at okhttp3.internal.http1.Http1Codec.readHeaderLine(Http1Codec.java:215) ~[okhttp-3.11.0.jar:na]
    at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:189) ~[okhttp-3.11.0.jar:na]
    ... 22 common frames omitted

Точка ошибки:

OkHttpClient httpClient = this.httpClient;
if (null != callBack) {
    OkHttpClient.Builder clientBuilder = httpClient.newBuilder();
    clientBuilder.addInterceptor(chain -> {
        ***Response response = chain.proceed(chain.request());***
...