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

Timeout is effectively half of what it should be #1883

Open
kyz opened this issue Jan 12, 2023 · 1 comment
Open

Timeout is effectively half of what it should be #1883

kyz opened this issue Jan 12, 2023 · 1 comment

Comments

@kyz
Copy link

kyz commented Jan 12, 2023

If I create a connection with a 30s timeout (e.g. Jsoup.connect().timeout(30000)), this allows:

  1. the initial connection to the web server to take up to 30s
  2. web server sending first byte of response to take up to 15s (half!)
  3. web server sending entire response to take up to 30s

All three should allow up to 30s.

The 15s anomaly is due to conn.setReadTimeout(req.timeout() / 2);

I understand that if you did conn.setConnectTimeout(30000) and conn.setReadTimeout(30000), then it might be 60s before the request completes, provided the webserver deliberately waited 29.999s before allowing the connection to open... but this is not fixed by halving the initial read timeout, it just reduces it to 45s (15s over the configured timeout).

I'd say it was much more common that connection is established quickly, then the web server takes its time servicing the request, only starting its response after several seconds of work. I'd like to say conn.timeout(30000) to allow the webserver 30s of time to do something with my request before giving any response. I don't want it to have a timeout after 15s (after the connection was established in 0.001s)

@BigFlagBurito
Copy link

It took me several hours today to find out why the timeout was always 30 seconds, even though I had set it to 60 seconds.
No wonder, when the number is divided by 2.
This should be better explained in the documentation or fixed, please.

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

No branches or pull requests

2 participants