Skip to content

🐛 http2: edge connections that die silently are never redialed; /ready still reports them as healthy #1772

Open

Description

@jyong-jobber

Describe the bug
With --protocol http2, if an edge connection dies without the local socket reporting an error, cloudflared never notices and never reconnects. The tunnel returns error 1033 to visitors indefinitely, while cloudflared reports itself healthy:

  • /ready returns {"status":200,"readyConnections":4,...}.
  • cloudflared_tunnel_ha_connections is 4.
  • cloudflared_tunnel_tunnel_register_success never increases, so no reconnect is ever attempted.
  • No errors are logged.

Only restarting cloudflared recovers it. I've seen it stay stuck for over 3 hours across several sleep/wake cycles. It reproduces reliably on a MacBook that sleeps, behind a corporate proxy that intercepts TCP. The machine can't use QUIC because UDP is blocked, hence http2.

To Reproduce

  1. Run a remotely-managed tunnel over http2: cloudflared tunnel --grace-period 0s run --protocol http2, with TUNNEL_TOKEN set.
  2. Confirm the tunnel hostname works.
  3. Let the Mac sleep (in my case anything from about 20 seconds to hours), then wake it.
  4. The hostname returns error 1033, while /ready and /metrics still report 4 healthy connections. It doesn't recover until cloudflared is restarted.

If it's an issue with Cloudflare Tunnel:

  • cloudflared config: remotely managed (token), a single ingress rule from the tunnel hostname to a local HTTP origin (http://localhost:3000)

Expected behavior
cloudflared should detect that an edge connection is dead, close it, and let the supervisor redial it, as it does when a connection errors.

Environment and versions

  • OS: macOS 26.7.1
  • Architecture: ARM (Apple Silicon)
  • Version: 2026.9.1 (Homebrew). The relevant code is unchanged on master as of 2026.10.1.

Logs and errors
There are no error logs. A goroutine dump taken while stuck (curl "127.0.0.1:20241/debug/pprof/goroutine?debug=2") shows all 4 connections' frame readers blocked in a read:

goroutine 194 [IO wait, 9 minutes]:
internal/poll.runtime_pollWait
crypto/tls.(*Conn).Read
net/http/internal/http2.readFrameHeader
net/http/internal/http2.(*Framer).ReadFrame
net/http/internal/http2.(*serverConn).readFrames
created by net/http/internal/http2.(*serverConn).serve
  ... github.com/cloudflare/cloudflared/connection.(*HTTP2Connection).Serve  connection/http2.go:83

Additional context
HTTP2Connection builds its http2.Server with only MaxConcurrentStreams set, so the HTTP/2 PING health check is off. A connection that receives no frames and gets no socket error blocks in readFrames forever. h2mux had a liveness check (--heartbeat-interval/--heartbeat-count), but those flags have been unused since h2mux was removed (TUN-7252), and http2 never got an equivalent. Server-side pings were added to golang.org/x/net in May 2024 (golang/go#67812).

Possibly related: #1339, which reports the same Mac-sleep symptom over QUIC. There the logs show QUIC retrying, so I've opened this separately for http2.

I have a small fix ready. It sets http.HTTP2Config{SendPingTimeout: 30s, PingTimeout: 15s} via ServeConnOpts.BaseConfig, with tests for both an unresponsive and a responsive edge. A patched build recovered by itself after sleeps where the unpatched build stayed stuck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions