square / okhttp

Square’s meticulous HTTP client for the JVM, Android, and GraalVM.
https://square.github.io/okhttp/
Apache License 2.0
45.71k stars 9.15k forks source link

not recover error of `REFUSED_STREAM error` #8531

Open caojiajun opened 1 week ago

caojiajun commented 1 week ago

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)
yschimke commented 1 week ago

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.

caojiajun commented 1 week ago

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

yschimke commented 1 week ago

Not by known issues.