fly-proxy sends TCP keepalive probes every ~5 s on idle client connections, costly for cellular IoT

We run an MQTT broker on Fly (TCP service on 8883 with handlers = ["tls"], MQTT keepalive 270 s). Our clients are battery-powered LTE-M devices.

The Fly edge sends a zero-length TCP keepalive probe on every idle client connection about every 5.12 s. The first probe comes 2–5 s after the last data. Our app never sees this traffic: the server-side socket shows only the MQTT PINGREQ/PINGRESP every 270 s.

Captured on fixed broadband (macOS, idle connection to a Fly app on 66.241.125.92:443):

07:55:24.198873 IP 66.241.125.92.443 > 192.168.1.176.59731: Flags [.], ack 67, win 1024, length 0
07:55:24.199066 IP 192.168.1.176.59731 > 66.241.125.92.443: Flags [.], ack 90, win 2048, length 0
07:55:29.318453 IP 66.241.125.92.443 > 192.168.1.176.59731: Flags [.], ack 67, win 1024, length 0
07:55:29.318634 IP 192.168.1.176.59731 > 66.241.125.92.443: Flags [.], ack 90, win 2048, length 0
07:55:34.438639 IP 66.241.125.92.443 > 192.168.1.176.59731: Flags [.], ack 67, win 1024, length 0
07:55:34.438854 IP 192.168.1.176.59731 > 66.241.125.92.443: Flags [.], ack 90, win 2048, length 0
07:55:39.558423 IP 66.241.125.92.443 > 192.168.1.176.59731: Flags [.], ack 67, win 1024, length 0

A modem trace from the device on 8883 shows the same probe (seq = snd_una − 1, length 0) every 5.12 s for hours.

On cellular, every probe pages the device and forces an RRC connection. Measured overnight it costs about 1.4 MB/day per device, more than 40 MB/month of pure keepalive. It also keeps the radio connected about 80 % of the time, which kills battery life. The connection itself is healthy: the device answers every probe.

From TCP idle timeouts restrictions have been removed we understand the edge sets SO_KEEPALIVE / TCP_KEEPIDLE / TCP_KEEPINTVL / TCP_KEEPCNT / TCP_USER_TIMEOUT on client sockets. We couldn’t find these values or any setting for them in the docs.

Questions:

  1. Is ~5 s really the intended TCP_KEEPIDLE/TCP_KEEPINTVL for client-side edge connections?
  2. Can it be raised (e.g. ≥ 300 s) or disabled per app or per service, for example as an option under [[services.ports]]? The application already has its own keepalive.
  3. If not, what is the recommended way to serve long-lived, mostly idle TCP connections to cellular clients on Fly?

Thanks!

Hi!
Thank you for the detailed report.

  1. Right now we hardcode it to
    TCP_KEEPIDLE = 2
    TCP_KEEPINTVL=5
    TCP_KEEPCNT=10
    TCP_USER_TIMEOUT=30

  2. There isn’t currently a user-facing setting to customize or disable these client-side keepalives. Making this configurable is something we could investigate, although exposing much longer intervals introduces operational considerations for proxy lifecycle management and upgrades.

Would an interval of around 60 seconds materially help your use case, or do you need intervals closer to your MQTT keepalive (270 seconds), or the ability to disable TCP keepalives entirely? Understanding the actual requirement would help me evaluate the available options.

  1. For a workaround today, one option is to terminate the client TCP connection on infrastructure you control and have that infrastructure maintain a separate connection to your Fly app. Depending on your protocol and device constraints, a UDP-based protocol such as MQTT-SN might also be worth considering, though that would require changes to the client and broker architecture.

Because I see this feature being requested from time to time by various users, for ex:

Thanks!
To answer your question, here’s what it means for a cellular IoT device (measured on LTE-M):

Edge keepalive Data/month 500 MB IoT SIM lasts Battery (1350 mAh)
today (5 s) ~44 MB ~11 months ~10 days
60 s ~6 MB ~7 years ~4 months
> 300 s (no probes) ~2 MB 10+ years ~1 year

So 60 s would help a lot. Ideal for us would be an idle time above our MQTT keepalive (270 s), or being able to turn it off per service since our app has its own keepalive.

Happy to test whenever there’s something to try.
Thanks for looking into it!

We see the same thing with a different protocol, and to answer your question: for us, 60 seconds would remove the probes entirely.

Our devices hold a TLS websocket (Phoenix channels) to our app on a raw TCP service. There’s no `tls` handler, because devices authenticate with client certificates, so TLS has to terminate in the app. Over half of our devices connect over LTE-M.

Our devices currently send a heartbeat every 30 s by default and the server replies, so a healthy connection never goes more than 30 s without traffic in both directions. With `TCP_KEEPIDLE = 2` and `TCP_KEEPINTVL = 5`, an otherwise idle device gets six probe round trips between each pair of heartbeats, and each one wakes its radio. They don’t catch anything our app misses: the server already closes any socket that has been silent for 3 minutes.

Any `TCP_KEEPIDLE` above 30 s means a healthy device is never probed, and 60 s leaves plenty of margin, and 180 s or more would also be great for us. We don’t need keepalives turned off. We’d be glad to test a per-app or per-service override.