not recover error of `REFUSED_STREAM error`
okhttpclient version: 4.9.3
occasional occurrence this error, and will not recover on its own, util restart process
okhttp3.internal.http2.StreamResetException: stream was reset: REFUSED_STREAM
at okhttp3.internal.http2.Http2Stream.takeHeaders(Http2Stream.kt:148)
at okhttp3.internal.http2.Http2ExchangeCodec.readResponseHeaders(Http2ExchangeCodec.kt:96)
at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:106)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:79)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.connection.ConnectInterceptor.intercept$sentryProxy(ConnectInterceptor.kt:34)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
There is logic to handle repeated refused stream failures and tests
https://github.com/square/okhttp/blob/master/okhttp%2Fsrc%2Fmain%2Fkotlin%2Fokhttp3%2Finternal%2Fconnection%2FRealConnection.kt
Without repro steps, I'm not sure how we can help you.
It's occasional, so I could not provide repro steps.
Is there any known bug/issue which can not recover on its own? I will upgrade to latest version 4.12.0
Not by known issues.
Closing as can't reproduce, will reopen if it can be.
It's very possible an OkHttp bug, but could also be app or server bug.
@caojiajun It seems I faced a similar issue and trying to investigate it. In your case, was it reproducible after the network disconnection/reconnection? Was there anything related to a Proxy or a VPN?
@caojiajun If you are using Android, use a real device instead of an emulator, and you will see the stability.
I solved it by using a real device