Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

What's the difference between connection timeout and connection read timeout?


Asked by Niklaus Hoffman on Dec 13, 2021 FAQ



HTTP also uses sockets internally. Connection timeout is different from the Connection Request timeout or connection read timeout. In many situations, the client doesn’t want to wait for a long time in that case a connection time out or Request connection timeout or both can be set.
Also,
ConnectTimeoutis the timeout for creating a connection. Let's say you have an unreliable server and you want to wait only 15 seconds before you tell the user that "something is wrong". ReadTimeoutis the timeout when you have a connection, you're blocked on read()and you want to get an exception if the read blocks for more than timeout.
Just so, If the client failed to so in a specified time, the server terminates this connection as it thinks that client is no longer there. This behaviour is intended to avoid wasting resources. When time out occurs the server returns a Request Timeout response with 408 status code.
Additionally,
Read timeout usually occurs within 40 to 60 seconds. Read timeout occurs when the socket is open, connection to the host server is established, the request is sent, but the response from the server is not received on time, and cannot be read.
Also Know,
Connection timeout is a common error that occurs whenever the client is waiting for too long before getting a response from any server (for API calls or browser requesting pages). This error is generated on the client side to terminate a connection, since we can only keep a limited number of open connections at the same time.