okhttp3.internal.http2.StreamResetException: stream was reset: PROTOCOL_ERROR/ CANCEL
See original GitHub issueI 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 :
try {
// Create a trust manager that does not validate certificate chains
final TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
@Override
public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
}
@Override
public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
}
@Override
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return new java.security.cert.X509Certificate[]{};
}
}
};
// Install the all-trusting trust manager
final SSLContext sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
// Create an ssl socket factory with our all-trusting manager
final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.sslSocketFactory(sslSocketFactory, (X509TrustManager) trustAllCerts[0]);
builder.hostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
return true;
}
});
OkHttpClient okHttpClient = builder.
build();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://xxx")
.client(okHttpClient)
.addConverterFactory(GsonConverterFactory.create())
.addConverterFactory(ScalarsConverterFactory.create())
.build();
final PublicApi request = retrofit.create(PublicApi.class);
Call<GetStatusSaveContactListModel> call = request.sendContactLists("saveContactList", obj.toString());
call.enqueue(new Callback<GetStatusSaveContactListModel>() {
@Override
public void onResponse(@NonNull Call<GetStatusSaveContactListModel> call, @NonNull Response<GetStatusSaveContactListModel> response) {
}
@Override
public void onFailure(@NonNull Call<GetStatusSaveContactListModel> call, Throwable t) {
}
});
} catch (Exception e) {
throw new RuntimeException(e);
}
And
@POST("/web_service/mobile/rest")
Call<GetStatusSaveContactListModel> sendContactLists(@Query("function") String function,
@Query("data") String data);
And
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.3.0'
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:44 (3 by maintainers)
Top Results From Across the Web
okhttp3.internal.http2.StreamResetException: stream was ...
StreamResetException : stream was reset: CANCEL at okhttp3.internal.http2.Http2Stream$FramingSource.checkNotClosed(Http2Stream.java:436) at ...
Read more >What causes "java.io.IOException: stream was reset: CANCEL ...
I'm experimenting with OKHttp (version 2.0.0-RC2) and SPDY and seeing IOException: stream was reset: CANCEL quite a lot, maybe 10% or more ...
Read more >okhttp3.internal.http2.StreamResetException: stream was reset
internal.http2.StreamResetException: stream was reset: PROTOCOL_ERROR. Hi everyone,. When i use okhttp3 to send event about 10 times (like ask ...
Read more >Stream Was Reset: Protocol_Error, While Using Retrofit In 3G ...
Indicates that the contacted node reported a protocol error. ... StreamResetException: stream was reset: CANCEL at okhttp3.internal.http2. in case the ...
Read more >Mobile Androind app: 'stream was reset: PROTOCOL_ERROR ...
IOException: stream was reset: PROTOCOL_ERROR at com.squareup.okhttp.internal.spdy.SpdyStream.getResponseHeaders(SpdyStream.java:145)
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is happening to me in production, but I am not able to reproduce the problem when debugging
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