avmohan
avmohan

Reputation: 1980

HTTP KeepAlive connection closed by server but client had sent a request in the mean time

The scenario is as below:

How should this race condition be handled: - All connection close should be initiated by proxy and never by the backend server? - Proxy should retry request when it fails to send because of connection close?

Upvotes: 2

Views: 3035

Answers (1)

Alex Sha
Alex Sha

Reputation: 49

Proxy just passes through the traffic. If the server has closed the connection, proxy should also immediately close it, even if there is a request pending. However, from the client site the described situation looks like server hasn't returned any data for the request. This should be prevented by 'keep-alive' handshake.

In HTTP protocol the header "Connection:" is used for such case. Client includes "Connection: Keep-Alive" if he wants to keep the TCP session open after the request will be processed (so it will be possible to send the next HTTP request within the same TCP session). Server still may reply with "Connection: Close" header, which means TCP session will be closed anyways.

Upvotes: 0

Related Questions