I have found two explanations on "connection timeout":
The server closes the socket connection when the client doesn't send any bytes to the server during [timeout] seconds. It appears to have some relation to HTTP header (Connection: keep-alive
).
The client stops attempting to connect to the server after [timeout] seconds if the socket connection was not established during that time.
So I am confused about the definition. What is a connection timeout? What is the difference between a client side connection timeout and a server side connection timeout?
And what's the difference between TimeToLive, connection timeout and request timeout?
I will try to answer it a little bit more informally.
Connection timeout - is a time period within which a connection between a client and a server must be established. Suppose that you navigate your browser (client) to some website (server). What happens is that your browser starts to listen for a response message from that server but this response may never arrive for various reasons (e.g. server is offline). So if there is still no response from the server after X seconds, your browser will 'give up' on waiting, otherwise it might get stuck waiting for eternity.
Request timeout - as in the previous case where client wasn't willing to wait for response from server for too long, server is not willing to keep unused connection alive for too long either. Once the connection between server and client has been established, client must periodically inform server that it is still there by sending information to that server. If client fails to send any information to server in a specified time, server simply drops this connection as it thinks that client is no longer there to communicate with it (why wasting resources meaninglessly).
Time to live (TTL) - is a value specified inside of a packet that is set when the packet is created (usually to 255) that tells how long the packet can be left alive in a network. As this packet goes through the network, it arrives at routers that sit on the path between the packet's origin and its destination. Each time a router forwards the packet to the next device, it also decrements its TTL value by 1. If that value drops to 0, instead of forwarding the packet, the router simply drops it as the packet is not supposed to live any longer. This mechanism is used to prevent a network from flooding by data, as each packet can be passed around only a limited number of times, i.e. it 'lives' inside of it only for a limited amount of 'time'.