11

I'm trying to understand the difference between:

setRequestTimeout - Set the maximum time in millisecond an AsyncHttpClient waits until the response is completed.

setReadTimeout - Set the maximum time in millisecond an AsyncHttpClient can stay idle.

When should I use one versus the other?

And how do they relate to a good old java.net.SocketTimeoutException: Read timed out?

tekumara
  • 8,357
  • 10
  • 57
  • 69
  • http://stackoverflow.com/questions/3069382/what-is-the-difference-between-connection-and-read-timeout-for-sockets – Abhishek Bansal Jul 07 '16 at 03:08
  • 1
    @AbhishekBansal - your link is talking about connection vs read timeouts, and is not specific to AsyncHttpClient – tekumara Jul 07 '16 at 04:34

1 Answers1

14

Request timeout = maximum duration for completing a request from the user's perspective. It can account for the time to resolve the hostname, to open the TCP connection, to perform TLS handshake, to write the request and receive the complete response.

Read timeout = maximum time between consecutive reads. Typically used to crash when a large download is no longer making any progress.

Yuri
  • 4,254
  • 1
  • 29
  • 46
Stephane Landelle
  • 6,990
  • 2
  • 23
  • 29