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

connectTimeout more than 30 seconds does not work for okhttp #5912

Closed
piyushspss opened this issue Mar 29, 2020 · 8 comments
Closed

connectTimeout more than 30 seconds does not work for okhttp #5912

piyushspss opened this issue Mar 29, 2020 · 8 comments
Labels
stackoverflow Referred to stackoverflow

Comments

@piyushspss
Copy link

I am trying to set connectTimeout to 2 minutes, but still the tries fails after 30 seconds only.

My client looks like this:

client = new OkHttpClient.Builder()
.callTimeout(2, TimeUnit.MINUTES)
.connectTimeout(2, TimeUnit.MINUTES)
.writeTimeout(2, TimeUnit.MINUTES)
.readTimeout(2, TimeUnit.MINUTES)
.build();

public Call callReq(Callback callback) {

Request.Builder builder = new Request.Builder()
        .url("http://203.0.113.1");

//Create request builder
final Request request = builder
        .build();

Call call = client.newCall(request);

call.enqueue(callback);
return call;

}
The failure response of this call I am receiving in 30 seconds. I wanted that to wait for 2 minutes. It works if I reduce the timeout to 15 seconds.

@piyushspss piyushspss added the bug Bug in existing code label Mar 29, 2020
@yschimke
Copy link
Collaborator

@yschimke yschimke added stackoverflow Referred to stackoverflow and removed bug Bug in existing code labels Mar 29, 2020
@chriswoodle
Copy link

chriswoodle commented Jan 8, 2021

I have the same issue, com.squareup.okhttp3:okhttp:3.12.0. My requests seem to exit after 30 sec, but no exception is thrown. On android.

@yschimke
Copy link
Collaborator

yschimke commented Jan 8, 2021

@chriswoodle If you can provide a reproducible test case we can investigate, otherwise I suggest discussing on the stackoverflow question.

@chriswoodle
Copy link

@yschimke I can put something together, It's somewhat involved though, Nodejs, ngrok and an android app.

@chriswoodle
Copy link

chriswoodle commented Jan 8, 2021

@yschimke I put something together, It's somewhat involved though, Nodejs, ngrok and an android app. https://github.com/chriswoodle/okhttp-issue Using com.squareup.okhttp3:okhttp:3.12.0, since this app must target api lvel 17.

I've tested the node express server using postman to confirm that it is not timing out requests.
image

I''ve tested setting the okhttpclient timeout to 15 sec, and that correctly throws an exception. However, with the timeout set to anything more than 30 sec. 30 sec after making a request the following comes back.

 <HTML>
    <HEAD>
    <TITLE>Inactivity Timeout</TITLE>
    </HEAD>
    
    <BODY BGCOLOR="white" FGCOLOR="black">
    <H1>Inactivity Timeout</H1>
    <HR>
    
    <FONT FACE="Helvetica,Arial"><B>
    Description: Too much time has passed without sending any data for document. 
    </B></FONT>
    <HR>
    </BODY>

Here are some android logs if they are helpful.
image

Let me know if I can do anything to help or test. Thanks.

@yschimke
Copy link
Collaborator

yschimke commented Jan 8, 2021

If your server is returning this error then there I not much OkHttp can do.

@chriswoodle
Copy link

That response is not from the server. It is however returned by the okhttpclient call. Maybe there is some other network issue with my hardware, I just tested in an emulator and there is no issue.

@chriswoodle
Copy link

Actually It looks like this was a network proxy issue and my request was being timed out by something else. Thank you for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stackoverflow Referred to stackoverflow
Projects
None yet
Development

No branches or pull requests

3 participants