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

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


Asked by Leo Dickson on Dec 13, 2021 FAQ



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. Specifically, if the server fails to send a byte <timeout> seconds after the last byte, a read timeout error will be raised.
Also Know,
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.
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.
Thereof,
Connection timeout (client side) VS Request timeout (server side) Connection timeoutis 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).
Furthermore,
If looks like you are setting the idle timeout lower than the request timeout, so it takes precedence. Your idle timeout settings should be longer than the request timeout, so for each request, the request timeout decides when to close the connection. Thanks for contributing an answer to Stack Overflow!