Supports configuration of all TCP Keepalive parameters per https://en.wikipedia.org/wiki/Keepalive
According to https://en.wikipedia.org/wiki/Keepalive, TCP Keepalive has three parameters:
-
Keepalive timeis the duration between two keepalive transmissions in idle condition. -
Keepalive intervalis the duration between two successive keepalive retransmissions, if acknowledgement to the previous keepalive transmission is not received. -
Keepalive retryis the number of retransmissions to be carried out before declaring that remote end is not available.
Currently, however, only the first parameter Keepalive time is configurable in hyper.
This CR is a proposed enhancement for a backward compatible change on the 0.14.x branch so that all the three TCP Keepalive parameters would become configurable.
FYI per empirical evidence enabling TCP keepalive with intervals and retries drastically/significantly improves the stability of persistent TCP connections while reducing the number of file descriptors via closing down dead connections.
I believe I've fixed all the stylistic issues reported by the workflow, but it doesn't seem I can trigger a re-run of the workflow. I also observed some workflow failures unrelated to this change, so they are probably existing failures.
Please let me know if I missed anything.
If possible, I'd like to have this change pushed/released asap, so I can make further PR to axum-server based on this change.
I see there are platform specific conditional compilations in the socket2 crate causing some failure. Looking into them.
Could just slap #[cfg(unix)] on the extra methods, and not worry about Windows...
Could just slap
#[cfg(unix)]on the extra methods, and not worry about Windows...
Right, but I am trying to make it such that the same API's can be provided to the upper layer, so that if a API/method exists for a specific parameter that isn't supported on a specific platform, then calling the API/method would just be a no-op. I've just pushed such changes, and added a few unit tests on it. Hopefully they would pass the platform specific tests now.
I used https://docs.rs/socket2/latest/socket2/struct.TcpKeepalive.html as the reference for the platform specific attributes for interval and retries.
Thanks for merging. Would this change also be merged into the master branch, or is it something that needs a separate PR? Please let me know if I can help.
The master branch has removed both Server and AddrIncoming. Helpers (such as Tokio integration) will now live in the hyper-util crate.