Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Async Http Client what is the difference between readTimeout and requestTimeout

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?

like image 897
tekumara Avatar asked Jul 07 '16 03:07

tekumara


People also ask

What is the difference between Readtimeout and Connecttimeout?

The connection timeout is the timeout in making the initial connection; i.e. completing the TCP connection handshake. The read timeout is the timeout on waiting to read data1.

What is asynchronous HTTP client?

Overview. AsyncHttpClient (AHC) is a library build on top of Netty, with the purpose of easily executing HTTP requests and processing responses asynchronously. In this article, we'll present how to configure and use the HTTP client, how to execute a request and process the response using AHC.

What is Readtimeout error?

From the client side, the “read timed out” error happens if the server is taking longer to respond and send information. This could be due to a slow internet connection, or the host could be offline. From the server side, it happens when the server takes a long time to read data compared to the preset timeout.

What is the difference between connection timeout and socket timeout?

connection timeout — a time period in which a client should establish a connection with a server. socket timeout — a maximum time of inactivity between two data packets when exchanging data with a server.


1 Answers

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.

like image 62
Stephane Landelle Avatar answered Sep 28 '22 06:09

Stephane Landelle