-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
Description
Having the server send a keep-alive header to the client with keep alive timeout hints would be useful.
In http 1.1 persistent connection protocol there is a timing race where the client sends the request and then the server kills the connection (due to inactivity) before receiving the client's request.
Currently the only way to mitigate this is to ensure the client has a shorter idle timeout than the server. Which currently is only guesswork unless you know the exact server settings/behavior. Providing a hint for the client would help alleviate this problem.
nginx does this:
From looking at nginx docs, it seems an header that is send from the server to the client.
From http://nginx.org/en/docs/http/ngx_http_core_module.html
The first parameter sets a timeout during which a keep-alive client connection will stay open on the server side. The zero value disables keep-alive client connections. The optional second parameter sets a value in the “Keep-Alive: timeout=time” response header field. Two parameters may differ.
The “Keep-Alive: timeout=time” header field is recognized by Mozilla and Konqueror. MSIE closes keep-alive connections by itself in about 60 seconds.
Originally posted by @mcollina in nodejs/undici#273 (comment)
A follow up for this would be to have the http client implement the corresponding functionality (i.e. reduce idle timeout based on hint).