I have encountered this problems in occasionally case, my website do NOT have this issue before today, when I encounter this issue, I try to resolve it by check my code and track issue log, even try stack-overflow, the anwser may the list:
- set retryOnConnectionFailure(true) when you create a OkHttpClient instance.
- set header("Connection","close")
- set header("Accept-Encoding", "identity")
But none of these could fix my issue, I also try to use addNetworkInterceptor to instead of addInterceptor, it does NOT work though.
Finally, I try to go back my previos version. Well, my previous code as follow:
response.setStatusCode(HttpStatus.UNAUTHORIZED);
return Mono.empty();
and now:
response.setStatusCode(HttpStatus.UNAUTHORIZED);
return response.writeAndFlushWith(Flux.just(Flux.fromStream(
Stream.generate(() -> ASRUtil.buildNLUResponse(ResponseEnum.TOKEN_NOT_EXIST))
.limit(1)
.map(ASRUtil::convertNLU2DataBuffer)
)));
I use the above code just want to reminder customers of their tokens invalid or NOT exists. But, it seems to cause the issue.
Any suggesion is welcome.
log attachment:
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
error point:
OkHttpClient httpClient = this.httpClient;
if (null != callBack) {
OkHttpClient.Builder clientBuilder = httpClient.newBuilder();
clientBuilder.addInterceptor(chain -> {
***Response response = chain.proceed(chain.request());***