Pooven
Pooven

Reputation: 1764

Keep alive and request timeouts

I understand that the keep-alive message aims to prevent the underlying TCP connection from closing so that multiple requests can be sent over the same TCP connection.

However it is unclear how this affects a request that has timed out:

Thank you for your time and assistance.

Upvotes: 1

Views: 3527

Answers (1)

Steffen Ullrich
Steffen Ullrich

Reputation: 123551

HTTP keep-alive (which should not be confused with TCP keep alive) asks the server to not close the connection after the HTTP response is fully sent. Thus HTTP keep-alive is only relevant for the time after the HTTP response is sent and before the next HTTP request will be received.

... when the client times-out, how will ASP.NET know?

The server is trying to read data. If the client closes the connection the server will get notified (like by reading 0 bytes) and will close the connection too.

... Surely the response can no longer be sent?

To repeat myself, HTTP keep-alive is only relevant after the full response was sent. So this question is unrelated to HTTP keep-alive.

Since the client can send keep-alive messages, what effect, if any does it have on the request?

No effect on the current request. But the client must be aware that the server might close the connection anytime after the HTTP response was sent and before the server gets the new request. Thus it might happen that the server closes the connection exactly in the moment when the client is trying to send a new request. In this case idempotent requests (GET) must be retried by the client within a new connection, while other requests should fail.

Upvotes: 5

Related Questions