looking for some solutions? You are welcome.

SOLVED: OkHttp3 never timeout on slow internet

Tanveer Munir:

First of all, I have read so many questions Regarding my question but it never gives me the solution. here is some of the Question which I read regarding my question.

I also Read this article regarding my question but it also never provide me the solution.

Problem

I am using Okhhtp3 Library in My application for Web Services. It's working fine but when the internet connection slow or unreliable connection it's stuck and never times out or never calls the timeout Exception or failure method.

Here is the client Code:

OkHttpClient client = new OkHttpClient.Builder()
            .connectTimeout(20, TimeUnit.SECONDS)
            .writeTimeout(20, TimeUnit.SECONDS)
            .readTimeout(20, TimeUnit.SECONDS)
            .retryOnConnectionFailure(false)
            .build();

How can get the timeout exception or called failure method after 20 secs?

Please help me. Thanks



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
Share:

No comments:

Recent