Open sealiasheq opened 6 years ago
yes, I am facing same issues, is there any solution yet?
i am also facing this issue
Exception occurs at okhttp3.internal.http2.StreamResetException: stream was reset: PROTOCOL_ERROR at okhttp3.internal.http2.Http2Stream$FramingSource.checkNotClosed(Http2Stream.java:436) at okhttp3.internal.http2.Http2Stream$FramingSource.read(Http2Stream.java:338) at okio.ForwardingSource.read(ForwardingSource.java:35) at okio.RealBufferedSource.read(RealBufferedSource.java:46) at okhttp3.internal.cache.CacheInterceptor$1.read(CacheInterceptor.java:174) at okio.RealBufferedSource$1.read(RealBufferedSource.java:430) at java.io.InputStream.read(InputStream.java:101)
This isn’t actionable as-is. Could you provide the server URL that triggers this? Or a test case that reproduces?
We are seeing the same issue with (openjdk version "11" 2018-09-25) and it is related to #3146, i.e. something with http/2.
We tried versions from 3.11.0 down to 3.3.0 and only 3.2.0 works for us. The strange thing is that sometimes we get this PROTOCOL_ERROR, but sometimes also http2.ConnectionShutdownException: null:
Caused by: okhttp3.internal.http2.ConnectionShutdownException: null
at okhttp3.internal.http2.Http2Connection.newStream(Http2Connection.java:247)
at okhttp3.internal.http2.Http2Connection.newStream(Http2Connection.java:230)
at okhttp3.internal.http2.Http2Codec.writeRequestHeaders(Http2Codec.java:113)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:50)
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:126)
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.execute(RealCall.java:77)
And sometimes stream cancel:
Caused by: okhttp3.internal.framed.StreamResetException: stream was reset: CANCEL
at okhttp3.internal.framed.FramedStream.getResponseHeaders(FramedStream.java:145)
at okhttp3.internal.http.Http2xStream.readResponseHeaders(Http2xStream.java:149)
at okhttp3.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:775)
at okhttp3.internal.http.HttpEngine.access$200(HttpEngine.java:86)
at okhttp3.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:760)
at okhttp3.internal.http.HttpEngine.readResponse(HttpEngine.java:613)
at okhttp3.RealCall.getResponse(RealCall.java:244)
at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:201)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:163)
at okhttp3.RealCall.execute(RealCall.java:57)
Also this is a rather rare issue but for certain requests reproducable. We'll try to produce a failing test for the latest 3.11.0
I have the same problem with okhttp3.12 + retrofit 2 The server is in golang 1.11.5 (gorilla/mux and I try also chi) My use case is to enqueue about 100 query, I have about 20% of the query which have a protocol_error
okhttp3.internal.http2.StreamResetException: stream was reset: PROTOCOL_ERROR 2019-02-03 23:52:09.691c W/System.err: at okhttp3.internal.http2.Http2Stream.takeHeaders(Http2Stream.java:158) 2019-02-03 23:52:09.691c W/System.err: at okhttp3.internal.http2.Http2Codec.readResponseHeaders(Http2Codec.java:131) 2019-02-03 23:52:09.691c W/System.err: at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88) 2019-02-03 23:52:09.691c W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 2019-02-03 23:52:09.692c W/System.err: at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45) 2019-02-03 23:52:09.692c W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 2019-02-03 23:52:09.692c W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) 2019-02-03 23:52:09.693c W/System.err: at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93) 2019-02-03 23:52:09.693c W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 2019-02-03 23:52:09.693c W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) 2019-02-03 23:52:09.693c W/System.err: at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) 2019-02-03 23:52:09.693c W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 2019-02-03 23:52:09.694c W/System.err: at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126) 2019-02-03 23:52:09.694c W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 2019-02-03 23:52:09.694c W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) 2019-02-03 23:52:09.695c W/System.err: at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:254) 2019-02-03 23:52:09.696c W/System.err: at okhttp3.RealCall$AsyncCall.execute(RealCall.java:200) 2019-02-03 23:52:09.696c W/System.err: at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) 2019-02-03 23:52:09.696c W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 2019-02-03 23:52:09.696c W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 2019-02-03 23:52:09.696c W/System.err: at java.lang.Thread.run(Thread.java:764)
Can you enable HTTP/2 frame logging and try again?
private static void enableHttp2FrameLogging() {
frameLogger = Logger.getLogger(Http2.class.getName());
frameLogger.setLevel(Level.FINE);
ConsoleHandler handler = new ConsoleHandler();
handler.setLevel(Level.FINE);
handler.setFormatter(new SimpleFormatter() {
@Override public String format(LogRecord record) {
return Util.format("%s%n", record.getMessage());
}
});
frameLogger.addHandler(handler);
}
}
tks for your very quick answer you can find the full log on https://pastebin.com/5rj2kQHL I hope you will find what is wrong I can also provide the go server and the java code if needed
My query is a POST always on the same URL it contains a JSON Body and there is an authorization bearer in the header
I also tryied to remove the header (the autorisation bearer), it doesn't work also.
Yep, that'd be handy. As small as you can make it please.
I set up for you a server with the golang server the endpoint is https://myvoip.w3france.com:10443/item/2 in POST For reasons I can't explain, there are less protocol problem with the server (about 3/4%) vs my dev machine on the same wifi network (in that case I use 4G) And last information, I have a OnePlus 5T with Android 9. Didn't try it from other device.
Retrofit.Builder builder =
new Retrofit.Builder()
.baseUrl("https://myvoip.w3france.com:10443/")
.addConverterFactory(GsonConverterFactory.create());
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
httpClient.protocols(Arrays.asList(Protocol.HTTP_2, Protocol.HTTP_1_1));
Retrofit retrofit = builder.client(httpClient.build()).build();
AuthService service = retrofit.create(AuthService.class);
// iterate over each item of the nomtable
for (int i = 0; i < 500; i++) {
final String id = Integer.toString(i);
RequestBody body = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), "");
Call<String> call = service.sendItem(id, body);
call.enqueue(new Callback<String>() {
@Override
public void onResponse(Call<String> call, Response<String> response) {
Log.d(TAG, "Success " + id);
}
@Override
public void onFailure(Call<String> call, Throwable t) {
Log.d(TAG, "Failure " + id);
Log.d(TAG, t.getMessage());
t.printStackTrace();
}
});
}
and AuthService.java
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.POST;
import retrofit2.http.Path;
public interface AuthService {
@POST("item/{item}")
Call<String> sendItem(
@Path("item") String itemGuid,
@Body RequestBody body);
}
Having the same issue; it happens always when there is bad connection (e.g. using 2G with bad signal). Trying to retrieve a JSON of ~80kB on 2G. I am using retrofit:2.5.0.
2019-02-28 14:14:34.304 22789-22789/? W/System.err: okhttp3.internal.http2.StreamResetException: stream was reset: PROTOCOL_ERROR
2019-02-28 14:14:34.305 22789-22789/? W/System.err: at okhttp3.internal.http2.Http2Stream$FramingSource.read(Http2Stream.java:420)
2019-02-28 14:14:34.307 22789-22789/? W/System.err: at okhttp3.internal.http2.Http2Codec$StreamFinishingSource.read(Http2Codec.java:205)
2019-02-28 14:14:34.307 22789-22789/? W/System.err: at okio.RealBufferedSource.read(RealBufferedSource.java:47)
2019-02-28 14:14:34.307 22789-22789/? W/System.err: at okio.RealBufferedSource.exhausted(RealBufferedSource.java:57)
2019-02-28 14:14:34.307 22789-22789/? W/System.err: at okio.InflaterSource.refill(InflaterSource.java:102)
2019-02-28 14:14:34.307 22789-22789/? W/System.err: at okio.InflaterSource.read(InflaterSource.java:62)
2019-02-28 14:14:34.307 22789-22789/? W/System.err: at okio.GzipSource.read(GzipSource.java:80)
2019-02-28 14:14:34.307 22789-22789/? W/System.err: at okio.RealBufferedSource.read(RealBufferedSource.java:47)
2019-02-28 14:14:34.307 22789-22789/? W/System.err: at okio.ForwardingSource.read(ForwardingSource.java:35)
2019-02-28 14:14:34.307 22789-22789/? W/System.err: at retrofit2.OkHttpCall$ExceptionCatchingResponseBody$1.read(OkHttpCall.java:296)
2019-02-28 14:14:34.307 22789-22789/? W/System.err: at okio.RealBufferedSource$1.read(RealBufferedSource.java:439)
2019-02-28 14:14:34.307 22789-22789/? W/System.err: at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:288)
2019-02-28 14:14:34.307 22789-22789/? W/System.err: at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:351)
2019-02-28 14:14:34.307 22789-22789/? W/System.err: at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:180)
2019-02-28 14:14:34.307 22789-22789/? W/System.err: at java.io.InputStreamReader.read(InputStreamReader.java:184)
2019-02-28 14:14:34.307 22789-22789/? W/System.err: at okhttp3.ResponseBody$BomAwareReader.read(ResponseBody.java:259)
2019-02-28 14:14:34.307 22789-22789/? W/System.err: at com.google.gson.stream.JsonReader.fillBuffer(JsonReader.java:1295)
2019-02-28 14:14:34.307 22789-22789/? W/System.err: at com.google.gson.stream.JsonReader.nextQuotedValue(JsonReader.java:1030)
2019-02-28 14:14:34.308 22789-22789/? W/System.err: at com.google.gson.stream.JsonReader.nextString(JsonReader.java:815)
2019-02-28 14:14:34.308 22789-22789/? W/System.err: at com.google.gson.internal.bind.TypeAdapters$16.read(TypeAdapters.java:402)
2019-02-28 14:14:34.308 22789-22789/? W/System.err: at com.google.gson.internal.bind.TypeAdapters$16.read(TypeAdapters.java:390)
2019-02-28 14:14:34.308 22789-22789/? W/System.err: at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
2019-02-28 14:14:34.308 22789-22789/? W/System.err: at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
2019-02-28 14:14:34.308 22789-22789/? W/System.err: at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41)
2019-02-28 14:14:34.308 22789-22789/? W/System.err: at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
2019-02-28 14:14:34.309 22789-22789/? W/System.err: at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
2019-02-28 14:14:34.309 22789-22789/? W/System.err: at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:39)
2019-02-28 14:14:34.309 22789-22789/? W/System.err: at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:27)
2019-02-28 14:14:34.309 22789-22789/? W/System.err: at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:223)
2019-02-28 14:14:34.309 22789-22789/? W/System.err: at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:121)
2019-02-28 14:14:34.310 22789-22789/? W/System.err: at okhttp3.RealCall$AsyncCall.execute(RealCall.java:206)
2019-02-28 14:14:34.310 22789-22789/? W/System.err: at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
2019-02-28 14:14:34.310 22789-22789/? W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
2019-02-28 14:14:34.311 22789-22789/? W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
2019-02-28 14:14:34.311 22789-22789/? W/System.err: at java.lang.Thread.run(Thread.java:764)
Issue is resolved by using HTTP 1.1 (not a good solution though):
List<Protocol> protocols = new ArrayList<>();
protocols.add(Protocol.HTTP_1_1);
httpClient.protocols(protocols);
Facing the same issue
Logs
2019-08-24 16:51:38.217 30729-30729/com.minimicro.sevenup W/System.err: okhttp3.internal.http2.StreamResetException: stream was reset: CANCEL 2019-08-24 16:51:38.217 30729-30729/com.minimicro.sevenup W/System.err: at okhttp3.internal.http2.Http2Stream.takeResponseHeaders(Http2Stream.java:153) 2019-08-24 16:51:38.217 30729-30729/com.minimicro.sevenup W/System.err: at okhttp3.internal.http2.Http2Codec.readResponseHeaders(Http2Codec.java:125) 2019-08-24 16:51:38.218 30729-30729/com.minimicro.sevenup W/System.err: at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88) 2019-08-24 16:51:38.218 30729-30729/com.minimicro.sevenup W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 2019-08-24 16:51:38.218 30729-30729/com.minimicro.sevenup W/System.err: at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45) 2019-08-24 16:51:38.218 30729-30729/com.minimicro.sevenup W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 2019-08-24 16:51:38.218 30729-30729/com.minimicro.sevenup W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) 2019-08-24 16:51:38.218 30729-30729/com.minimicro.sevenup W/System.err: at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93) 2019-08-24 16:51:38.218 30729-30729/com.minimicro.sevenup W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 2019-08-24 16:51:38.218 30729-30729/com.minimicro.sevenup W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) 2019-08-24 16:51:38.219 30729-30729/com.minimicro.sevenup W/System.err: at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) 2019-08-24 16:51:38.219 30729-30729/com.minimicro.sevenup W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 2019-08-24 16:51:38.219 30729-30729/com.minimicro.sevenup W/System.err: at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126) 2019-08-24 16:51:38.219 30729-30729/com.minimicro.sevenup W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 2019-08-24 16:51:38.219 30729-30729/com.minimicro.sevenup W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) 2019-08-24 16:51:38.219 30729-30729/com.minimicro.sevenup W/System.err: at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:212) 2019-08-24 16:51:38.219 30729-30729/com.minimicro.sevenup W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 2019-08-24 16:51:38.219 30729-30729/com.minimicro.sevenup W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) 2019-08-24 16:51:38.219 30729-30729/com.minimicro.sevenup W/System.err: at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200) 2019-08-24 16:51:38.220 30729-30729/com.minimicro.sevenup W/System.err: at okhttp3.RealCall$AsyncCall.execute(RealCall.java:147) 2019-08-24 16:51:38.220 30729-30729/com.minimicro.sevenup W/System.err: at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) 2019-08-24 16:51:38.220 30729-30729/com.minimicro.sevenup W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 2019-08-24 16:51:38.220 30729-30729/com.minimicro.sevenup W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 2019-08-24 16:51:38.220 30729-30729/com.minimicro.sevenup W/System.err: at java.lang.Thread.run(Thread.java:764)
Lib's
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.5.0'
Call
@Multipart
@POST(EnumsClass.API_URL.addAudit)
Call
BuilderClass
static Gson gson = new GsonBuilder() .setLenient() .serializeNulls() .create();
public static Retrofit getClient(String baseUrl, OkHttpClient.Builder okhhtpBuilder) {
if (retrofit == null) {
retrofit = new Retrofit.Builder()
.baseUrl(baseUrl)
.client(okhhtpBuilder.build())
.addConverterFactory(GsonConverterFactory.create(gson))
.build();
}
return retrofit;
}
Any update on this? StackTrace:
Fatal Exception: okhttp3.internal.http2.StreamResetException: stream was reset: PROTOCOL_ERROR at okhttp3.internal.http2.Http2Stream.takeHeaders(Http2Stream.java:158) at okhttp3.internal.http2.Http2Codec.readResponseHeaders(Http2Codec.java:131) 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:126) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) at ai.beans.driver.networking.NetworkInterceptor.intercept(NetworkInterceptor.kt:22) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:254) at okhttp3.RealCall$AsyncCall.execute(RealCall.java:200) at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:764)
we are having the same issue.
I'm also having the same issue and it is crashing the app. Caused by okhttp3.internal.http2.StreamResetException: stream was reset: CANCEL at okhttp3.internal.http2.Http2Stream$FramingSource.read(Http2Stream.java:381) at okhttp3.internal.http2.Http2Codec$StreamFinishingSource.read(Http2Codec.java:213) at okio.RealBufferedSource.read(RealBufferedSource.kt:41) at okhttp3.internal.cache.CacheInterceptor$1.read(CacheInterceptor.java:174) at okio.RealBufferedSource.read(RealBufferedSource.kt:41) at okio.ForwardingSource.read(ForwardingSource.kt:29) at retrofit2.OkHttpCall$ExceptionCatchingRequestBody$1.read(OkHttpCall.java:290) at okio.RealBufferedSource.request(RealBufferedSource.kt:62) at com.squareup.moshi.JsonUtf8Reader.nextNonWhitespace(JsonUtf8Reader.java:996) at com.squareup.moshi.JsonUtf8Reader.doPeek(JsonUtf8Reader.java:309) at com.squareup.moshi.JsonUtf8Reader.peek(JsonUtf8Reader.java:193)
faced this issue on Samsung SM-N960F (and 3 other models of Samsung, Android 8). on Xiaomi/Lenovo everything is ok. probably triggered by unstable connection
Have we got any update on this? I get this when i trigger a specific api in quick succession for example: API called API called again (before i could get response) throws StreamResetException
but if i call the API wait for some time i get the response API called . . . waiting . . after some waiting finally i get the response
I set up for you a server with the golang server the endpoint is https://myvoip.w3france.com:10443/item/2 in POST For reasons I can't explain, there are less protocol problem with the server (about 3/4%) vs my dev machine on the same wifi network (in that case I use 4G) And last information, I have a OnePlus 5T with Android 9. Didn't try it from other device.
Retrofit.Builder builder = new Retrofit.Builder() .baseUrl("https://myvoip.w3france.com:10443/") .addConverterFactory(GsonConverterFactory.create()); OkHttpClient.Builder httpClient = new OkHttpClient.Builder(); httpClient.protocols(Arrays.asList(Protocol.HTTP_2, Protocol.HTTP_1_1)); Retrofit retrofit = builder.client(httpClient.build()).build(); AuthService service = retrofit.create(AuthService.class); // iterate over each item of the nomtable for (int i = 0; i < 500; i++) { final String id = Integer.toString(i); RequestBody body = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), ""); Call<String> call = service.sendItem(id, body); call.enqueue(new Callback<String>() { @Override public void onResponse(Call<String> call, Response<String> response) { Log.d(TAG, "Success " + id); } @Override public void onFailure(Call<String> call, Throwable t) { Log.d(TAG, "Failure " + id); Log.d(TAG, t.getMessage()); t.printStackTrace(); } }); }
and AuthService.java
import okhttp3.RequestBody; import okhttp3.ResponseBody; import retrofit2.Call; import retrofit2.http.Body; import retrofit2.http.POST; import retrofit2.http.Path; public interface AuthService { @POST("item/{item}") Call<String> sendItem( @Path("item") String itemGuid, @Body RequestBody body); }
yeah face same issue in Oneplus 5T
i have this issue
I want to check if we are indeed receiving RST_STREAM frame on an Android client. The instructions in this link doesn't seem to work anymore. https://square.github.io/okhttp/debug_logging/ How can I enable frame logging for Android client?
Thanks for flagging, I'll fix the instructions. Will answer this evening, if noone else beats me to it.
@shrutigupta23 In theory now, all that should be required to enable framelogging via adb is the following
$ adb shell setprop log.tag.okhttp.Http2 DEBUG
$ adb logcat '*:E' 'okhttp.Http2:D'
...
05-28 19:31:32.365 8472 8505 D okhttp.Http2: >> CONNECTION 505249202a20485454502f322e300d0a0d0a534d0d0a0d0a
05-28 19:31:32.366 8472 8505 D okhttp.Http2: >> 0x00000000 6 SETTINGS
05-28 19:31:32.368 8472 8505 D okhttp.Http2: >> 0x00000000 4 WINDOW_UPDATE
05-28 19:31:32.374 8472 8509 D okhttp.Http2: << 0x00000000 18 SETTINGS
05-28 19:31:32.374 8472 8509 D okhttp.Http2: << 0x00000000 4 WINDOW_UPDATE
05-28 19:31:32.379 8472 8505 D okhttp.Http2: >> 0x00000003 45 HEADERS END_STREAM|END_HEADERS
05-28 19:31:32.382 8472 8510 D okhttp.Http2: >> 0x00000000 0 SETTINGS ACK
05-28 19:31:32.389 8472 8509 D okhttp.Http2: << 0x00000000 0 SETTINGS ACK
05-28 19:31:32.408 8472 8509 D okhttp.Http2: << 0x00000003 373 HEADERS END_HEADERS
05-28 19:31:32.412 8472 8509 D okhttp.Http2: << 0x00000003 230 DATA END_STREAM
05-28 19:31:32.412 8472 8509 D okhttp.Http2: << 0x00000000 8 PING
05-28 19:31:32.413 8472 8511 D okhttp.Http2: >> 0x00000000 8 PING ACK
05-28 19:31:32.523 8472 8505 D okhttp.Http2: >> CONNECTION 505249202a20485454502f322e300d0a0d0a534d0d0a0d0a
05-28 19:31:32.524 8472 8505 D okhttp.Http2: >> 0x00000000 6 SETTINGS
05-28 19:31:32.525 8472 8505 D okhttp.Http2: >> 0x00000000 4 WINDOW_UPDATE
05-28 19:31:32.529 8472 8505 D okhttp.Http2: >> 0x00000003 49 HEADERS END_STREAM|END_HEADERS
05-28 19:31:32.556 8472 8512 D okhttp.Http2: << 0x00000000 18 SETTINGS
05-28 19:31:32.556 8472 8512 D okhttp.Http2: << 0x00000000 4 WINDOW_UPDATE
05-28 19:31:32.557 8472 8512 D okhttp.Http2: << 0x00000000 0 SETTINGS ACK
05-28 19:31:32.557 8472 8511 D okhttp.Http2: >> 0x00000000 0 SETTINGS ACK
05-28 19:31:32.564 8472 8512 D okhttp.Http2: << 0x00000003 375 HEADERS END_HEADERS
05-28 19:31:32.568 8472 8512 D okhttp.Http2: << 0x00000003 1841 DATA PADDED
05-28 19:31:32.568 8472 8512 D okhttp.Http2: << 0x00000003 15 DATA END_STREAM|PADDED
05-28 19:31:32.569 8472 8512 D okhttp.Http2: << 0x00000000 8 PING
05-28 19:31:32.569 8472 8510 D okhttp.Http2: >> 0x00000000 8 PING ACK
But the instructions you linked are broken for Java also, the path of the link changed. I'll update that as well.
Happens randomly with OkHttp3 too, using Amazon CloudFront in HTTP/2 mode. Most likely related to slow network connection.
okhttp3.internal.http2.StreamResetException: stream was reset: CANCEL The same problem happened in Http2, the okhttp version is 3.14.9, does it have a solution?
You can check you are not calling cancel()
too early.
IIRC, I had that issue because I made a mistake in an extension where I was calling cancel after a successful response, which would make reading it fail with this exception.
You can check you are not calling
cancel()
too early.IIRC, I had that issue because I made a mistake in an extension where I was calling cancel after a successful response, which would make reading it fail with this exception.
@LouisCAD Thanks, but I'm not using cacel() in my code, it happens always when there is bad connection.
You can check you are not calling
cancel()
too early. IIRC, I had that issue because I made a mistake in an extension where I was calling cancel after a successful response, which would make reading it fail with this exception.@LouisCAD Thanks, but I'm not using cacel() in my code, it happens always when there is bad connection.
@vanminh2501 You resolved this problem? I'm having this in this week.
Having the same issue, random
okhttp3.internal.http2.StreamResetException: stream was reset: PROTOCOL_ERROR
on v 3.12
@goacoustic please provide frame logging or event listener logging so we can investigate, this one line doesn't help investigate. Thanks, this would be really helpful.
This is happening to me in production, but I am not able to reproduce the problem when debugging
Non-fatal Exception: okhttp3.internal.http2.StreamResetException: stream was reset: CANCEL
at okhttp3.internal.http2.Http2Stream.takeHeaders(Http2Stream.java:158)
at okhttp3.internal.http2.Http2Codec.readResponseHeaders(Http2Codec.java:131)
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:126)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:254)
at okhttp3.RealCall.execute(RealCall.java:92)
at com.google.firebase.perf.network.FirebasePerfOkHttpClient.execute(FirebasePerfOkHttpClient.java:43)
at retrofit2.OkHttpCall.execute(OkHttpCall.java:186)
at retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:45)
at io.reactivex.Observable.subscribe(Observable.java:12090)
at retrofit2.adapter.rxjava2.BodyObservable.subscribeActual(BodyObservable.java:34)
at io.reactivex.Observable.subscribe(Observable.java:12090)
at io.reactivex.internal.operators.observable.ObservableSingleSingle.subscribeActual(ObservableSingleSingle.java:35)
at io.reactivex.Single.subscribe(Single.java:3438)
at io.reactivex.internal.operators.single.SingleToObservable.subscribeActual(SingleToObservable.java:35)
at io.reactivex.Observable.subscribe(Observable.java:12090)
at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeTask.run(ObservableSubscribeOn.java:96)
at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:578)
at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)
at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
Since this is a popular issue, I wanted to confirm two assumptions I'm under
1) Since StreamResetException is an IOException, it's mere presence should be handled by apps without crashing, similar to any general network error. 2) It seems like it's either slow networks, or specific middleware handling of HTTP/2 that differs against HTTP/1.1. So possibly only happens when you overload a single server with multiple requests, while HTTP/1.1 would naturally load balance better. Or head of line blocking causing a bunch of later requests to be delayed while HTTP/1.1 may allow small requests to succeed.
Do these assumptions seem valid?
Our users are mostly using networks with poor quality, both in bandwidth and stability. We're using Google's External HTTPS Load Balancer, so I doubt that it was an overloaded server in our case. (I've been following this issue for the past few months, we have dropped clients to HTTP/1.1 for now).
@mlazowik Yep - I'm assuming your case may possibly be the one I mentioned above "Or head of line blocking causing a bunch of later requests to be delayed while HTTP/1.1 may allow small requests to succeed."
I'm guessing you mean something that's described here: https://www.twilio.com/blog/2017/10/http2-issues.html?
Nice link. Thanks.
try checking if you have used less time, Increasing time duration solved the problem
.readTimeout(this.timeout, TimeUnit.SECONDS)
.connectTimeout(this.timeout, TimeUnit.SECONDS)
.pingInterval(this.timeout, TimeUnit.MILLISECONDS)
return new OkHttpClient.Builder()
//.readTimeout(this.timeout, TimeUnit.SECONDS)
//.connectTimeout(this.timeout, TimeUnit.SECONDS)
//.pingInterval(200, TimeUnit.MILLISECONDS)
.addInterceptor(new HeaderInterceptor(this.authtoken))
.retryOnConnectionFailure(true)
.build();
I'm getting StreamResetException: stream was reset: CANCEL
.
Have anyone checked whether it can be related to query length?
I can reproduce it stably in our use case: we have to use a GET with a very long query. The exception is thrown if the query is longer than 5653 characters, but ok if it is 5594 (I didn't test values in-between).
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
implementation 'org.conscrypt:conscrypt-android:2.5.2'
(first noticed in July 2020 with older versions)
The server is nginx (1.14.2).
we are having the same issue.
2021-09-17 16:04:26.979 W/System.err: okhttp3.internal.http2.StreamResetException: stream was reset: PROTOCOL_ERROR
2021-09-17 16:04:26.979 W/System.err: at okhttp3.internal.http2.Http2Stream$FramingSource.read(Http2Stream.java:381)
2021-09-17 16:04:26.979 W/System.err: at okhttp3.internal.http2.Http2Codec$StreamFinishingSource.read(Http2Codec.java:213)
2021-09-17 16:04:26.979 W/System.err: at okio.RealBufferedSource$1.read(RealBufferedSource.java:447)
2021-09-17 16:04:26.979 W/System.err: at java.io.InputStream.read(InputStream.java:101)
2021-09-17 16:04:26.979 W/System.err: at com.bumptech.glide.load.model.ComicStreamEncoder.encode(ComicStreamEncoder.kt:46)
2021-09-17 16:04:26.979 W/System.err: at com.bumptech.glide.load.model.ComicStreamEncoder.encode(ComicStreamEncoder.kt:21)
2021-09-17 16:04:26.979 W/System.err: at com.bumptech.glide.load.engine.DataCacheWriter.write(DataCacheWriter.java:31)
2021-09-17 16:04:26.979 W/System.err: at com.bumptech.glide.load.engine.cache.DiskLruCacheWrapper.put(DiskLruCacheWrapper.java:134)
2021-09-17 16:04:26.979 W/System.err: at com.bumptech.glide.load.engine.SourceGenerator.cacheData(SourceGenerator.java:79)
2021-09-17 16:04:26.980 W/System.err: at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:46)
2021-09-17 16:04:26.980 W/System.err: at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:302)
2021-09-17 16:04:26.980 W/System.err: at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:272)
2021-09-17 16:04:26.980 W/System.err: at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:233)
2021-09-17 16:04:26.980 W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
2021-09-17 16:04:26.980 W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
2021-09-17 16:04:26.980 W/System.err: at java.lang.Thread.run(Thread.java:929)
We have same issue !
httpClient.protocols( Collections.singletonList(Protocol.HTTP_1_1) );
This what worked for me.
https://stackoverflow.com/questions/53648852/how-to-solve-okhttp3-internal-http2-streamresetexception-stream-was-reset-refu
repeat url cancel, cancel not error.
你好,你的邮件已经收到。我会尽快给你回复。
这是来自QQ邮箱的假期自动回复邮件。你好,我最近正在休假中,无法亲自回复你的邮件。我将在假期结束后,尽快给你回复。
If you want to keep the advantages of http2, like header compression, instead of dropping to http1.1 – http3 gets rid of the head of line blocking issues. On android you can replace okhttp with cronet to get http3 support, you obviously need to support it on your server(s) too.
okHttpClient = builder.protocols(Arrays.asList(Protocol.HTTP_1_1)).build()
It's Kotlin version. It worked for me. Put the 'Protocol.HTTP_1_1' in your okhttp client.
okHttpClient = builder.protocols(Arrays.asList(Protocol.HTTP_1_1)).build()
It's Kotlin version. It worked for me. Put the 'Protocol.HTTP_1_1' in your okhttp client.
What okhttp and Nginx version and Android version did you use? @songmik
Nobody was able to reproduce the problem, I think it is warmly recommended
Le dim. 5 mars 2023, 21:04, Dmitriy @.***> a écrit :
I'm facing the same problem using following url: https://api.alquran.cloud/v1/quran/en.husary
The workarounds suggested do not help me. I see that the issue is old, would it be useful to create a minimal reproducible example?
— Reply to this email directly, view it on GitHub https://github.com/square/okhttp/issues/3955#issuecomment-1455190249, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABM5FPFP4NH5ALRQTVTHN6DW2TWVVANCNFSM4EY2VZ3Q . You are receiving this because you commented.Message ID: @.***>
Nobody was able to reproduce the problem, I think it is warmly recommended Le dim. 5 mars 2023, 21:04, Dmitriy @.***> a écrit : …
I'm sorry, but this particular url seems to be broken. If you open it in the browser there is no end of the json
My problem was related to CompositeDisposable.
I am using RxJava3 as callAdapter. If you add the call disposable to a CompositeDisposable that is disposed the error occurs. I don't think this is the solution for all of us who have this problem but it might be a good clue to find out what is happening.
okHttpClient = builder.protocols(Arrays.asList(Protocol.HTTP_1_1)).build()
It's Kotlin version. It worked for me. Put the 'Protocol.HTTP_1_1' in your okhttp client.What okhttp and Nginx version and Android version did you use? @songmik
Oh I'm sorry, I can't figured out What Nginx version is .. But Okhttp version is 4.9.3. Anyway I found my problem. The Problem was in my code. I got "Connection", "Close" . I removed 'close'. I think 'close' is the default on HTTP/1.0 requests. So remove the close or change it to keep-alive.
Good luck : )
I am connecting to web service with last version
retrofit
but get me bellow error :okhttp3.internal.http2.StreamResetException: stream was reset: PROTOCOL_ERROR
My code is like bellow :
And
And