question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

java.io.IOException: unexpected end of stream on okhttp3.Address@###

See original GitHub issue

#2147 - in previous version there was also this issue and was apparently not resolved

While I am trying to connect to one of webservices used in my app on first attempt I get mentioned in title error, then after retry I got correct data. My configuration of okHttpClient:

    @Provides
    @Singleton
    HttpLoggingInterceptor providesHttpLoggingInterceptor() {
        HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
        interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        return interceptor;
    }

    @Provides
    @Singleton
    StethoInterceptor providesStethoInterceptor(){
        return new StethoInterceptor();
    }

    @Provides
    @Singleton
    OkHttpClient providesOKClient(HttpLoggingInterceptor interceptor, StethoInterceptor stethoInterceptor) {
        return new OkHttpClient.Builder()
                .addInterceptor(interceptor)
                .addNetworkInterceptor(stethoInterceptor)
                .retryOnConnectionFailure(true)
                .connectTimeout(15, TimeUnit.SECONDS)
                .readTimeout(20, TimeUnit.SECONDS)
                .build();
    }

In the attachment there is screenshot from Stetho showing the situation and addreses I try to connect with. issue

Calls are made with Retrofit 2 - beta4 using Call asynchronous.

There is no rule when issue is occuring down, so I only leave it here.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
whalemarecommented, Mar 30, 2018

@dimsuz our nginx cached large responses into local folder /tmp/cache/nginx/some-cache-folder. This some-cache-folder has incorrect access rights and nginx close connectiond immediatly, when ended its inner buffer, without save responses into folder. So magic trick)

1reaction
datvong-wmcommented, Apr 18, 2018

Got the same error. Turns out turning off BODY logging fixed it for us.

interceptor.setLevel(HttpLoggingInterceptor.Level.NONE);

Read more comments on GitHub >

github_iconTop Results From Across the Web

IOException: unexpected end of stream on okhttp3.Address ...
The error occurs when OkHttp try to reuse a connection that is in FIN_WAIT2 state in server, because the server keep_alive timeout is...
Read more >
Android OkHttp HTTP FAILED: java.io.IOException
I/okhttp.OkHttpClient: <-- HTTP FAILED: java.io.IOException: unexpected end of stream on http://10.0.2.2:30000/... java.io.
Read more >
unexpected end of stream on com.android.okhttp.Address ...
and this is the error: Java.IO.IOException: unexpected end of stream on com.android.okhttp.Address@403f40ec ---> Java.IO.
Read more >
unexpected end of stream on okhttp3.Address@2c98c95e - B4X
Hi all, today I'm encountering this error message while connecting to my VPS where a B4J module is listening in order to serve...
Read more >
IOException unexpected end of stream when listing locations ...
It appears that okhttp3 is falling over on itself inside the API. If I resend the request it tends to then go through...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found