Comment by karmanyaahm

3 years ago

I ran into a similar phantom-traffic problem from Go ignoring the Linux default for TCP keepalives and sending them every 15 seconds, very wasteful for mobile devices. While I quite like the rest of Go, I don't see why they have to be so opinionated and ignore the OS in their network defaults.

My PR fixing that in Caddy: https://github.com/caddyserver/caddy/pull/4865

To be fair, the linux defaults of 2h are not working in most enterprise or cloud environments. One frequently encounter load balancers, firewalls and other proxies that drop connections after around 5-15 minutes. 15 seconds sounds very aggressive though.

  • The default of 2h is not just a Linux default; it's straight up from the RFC.

    https://www.rfc-editor.org/rfc/rfc9293.html#name-tcp-keep-al...

    > Keep-alive packets MUST only be sent when no sent data is outstanding, and no data or acknowledgment packets have been received for the connection within an interval (MUST-26). This interval MUST be configurable (MUST-27) and MUST default to no less than two hours (MUST-28).