jsoup icon indicating copy to clipboard operation
jsoup copied to clipboard

Timeout is effectively half of what it should be

Open kyz opened this issue 2 years ago • 1 comments

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)

kyz avatar Jan 12 '23 15:01 kyz

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.

BigFlagBurito avatar Apr 03 '24 20:04 BigFlagBurito