Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

okhttp3.internal.http2.StreamResetException: stream was reset: INTERNAL_ERROR #3936

Closed
smi22 opened this issue Mar 26, 2018 · 9 comments
Closed
Labels
needs info More information needed from reporter

Comments

@smi22
Copy link

smi22 commented Mar 26, 2018

Api call with retrofit and rxandroid

Depencency used:
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'io.reactivex.rxjava2:rxjava:2.1.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.6.0'

Here is setup:
public static IAPIInterface getRestAdapterForRx() {

    HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
    logging.setLevel(HttpLoggingInterceptor.Level.BODY);
    OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
    httpClient.addInterceptor(logging);

    Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(BASE_URL)
            .addConverterFactory(GsonConverterFactory.create())
            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
            .client(httpClient.build())
            .build();

    return retrofit.create(IAPIInterface.class);
}

Mostly, API Call gives response but some time it give this error.

@swankjesse
Copy link
Collaborator

Typically error code is sent by a server to indicate a problem server-side. It could also happen if OkHttp’s stream reader crashes with an unexpected exception.

Could you provide a standalone test case? As-is there’s no action we can take on this.

@swankjesse swankjesse added the needs info More information needed from reporter label Mar 29, 2018
@tobydigz
Copy link

tobydigz commented Mar 5, 2019

A sample project to reproduce this error can be found here https://github.com/tobydigz/TestRetrofitApp

What I know so far is that

  • I only get this error when I receive a 401 while attempting a GET. Might be due to the server I don't know.
  • The logging interceptor cuts off abruptly but when I try the same endpoint from Postman, I get a response body.

I could also provide a base url if that's necessary, to help with pinpointing the error

So dependencies used are

  • implementation "com.squareup.okhttp3:okhttp:3.13.1"
  • implementation "com.squareup.retrofit2:retrofit:2.3.0"
  • implementation "com.squareup.okhttp3:logging-interceptor:3.13.1"
  • implementation "com.squareup.retrofit2:adapter-rxjava2:2.3.0"
  • implementation "com.squareup.retrofit2:converter-moshi:2.3.0"
  • implementation "io.reactivex.rxjava2:rxjava:2.1.7"
  • implementation "io.reactivex.rxjava2:rxkotlin:2.1.0"
  • implementation "io.reactivex.rxjava2:rxandroid:2.0.1"
  • implementation "com.squareup.moshi:moshi-kotlin:1.8.0"

@swankjesse
Copy link
Collaborator

Is postman using HTTP/2? I think it's a server-triggered failure.

@tobydigz
Copy link

tobydigz commented Mar 5, 2019

Is postman using HTTP/2? I think it's a server-triggered failure.

I'm not sure but when I set Okhttp to use HTTP/1.1 I get End Of File Exception instead.
Also an Angular and C client interacting with this endpoint don't experience this issue, just the Android client

@swankjesse
Copy link
Collaborator

Can you isolate the difference? Maybe send the C client’s headers with OkHttp?

@hakansuluoglu
Copy link

Is postman using HTTP/2? I think it's a server-triggered failure.

I am facing the same problem when the response code is 503. Postman and ios client do not get anything like this error. Client headers are the same.

Can you explain "server-triggered" failure?

@chanjungkim
Copy link

chanjungkim commented Dec 4, 2020

What's the problem?? ... I can't find the solution. Using Http1.1 gets close error.

@chanjungkim
Copy link

chanjungkim commented Dec 4, 2020

I found that the server can't send all data properly. For instance, JSON isn't complete(the braces aren't closed properly at the end). It's server problem. I guess it's instance problem. the instance must have some limit for that. So, you need to enlarge the size.

ex.

{
"name": "john",
"address": "a b c",
... // at 3000th lines
"na // end with incompletely

the rest of it is missing.

UPDATE

it was Nginx buffer size problem.

If you are using AWS EC2,

Go to /etc/nginx/default.d/server.conf

proxy_redirect off;
proxy_buffering off;

@sschuberth
Copy link
Contributor

Seems like I'm getting the same error when trying to download with OkHttp from https://hg.openjdk.org/jdk-updates/jdk9u/archive/1b1226687b89.zip. Via Firefox the downloads works just fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs info More information needed from reporter
Projects
None yet
Development

No branches or pull requests

7 participants