ข้ามไปยังเนื้อหา

Issue: Gateway cloudflared QUIC flap → SSH tunnel intermittently unreachable; fixed via http2 + pinned 2026.7.1

  • Date: 2026-07-10 (found during follow-up of #2; fixed same evening ~19:53 +07)
  • GitHub issue: racksync/obh-iot#3
  • Status: ✅ Fixed & verified (live on http2 + cloudflare/cloudflared:2026.7.1)
  • Area: Gateway VM 194.1.0.3 / Cloudflare Tunnel (cloudflared-tunnel docker container, network_mode: host)
  • Found by: RACKSYNC (Damrongwit), while verifying the conntrack fix (#2)
  • Owner: RACKSYNC (Damrongwit)

ssh root@cf-rilf-gw hung at banner exchange (3/3 attempts) even though the gateway host was fully healthy — ping 0% loss @0.12 ms, port 22 open, load 0, conntrack only 1.9% used. Cloudflare edge/Access answered (no browser re-prompt), but the SSH stream to the origin never completed. This is distinct from the conntrack outage of #2 (that was a host-wide packet drop; here the box is healthy and only the tunnel stream fails).

docker logs cloudflared-tunnel showed recurring QUIC edge-connection flaps:

ERR failed to accept incoming stream requests error="failed to accept QUIC stream: timeout: no recent network activity"
WRN Failed to dial a quic connection error="failed to dial to edge with quic: timeout: no recent network activity"
INF Retrying connection ... Connection terminated ... Registered tunnel connection (repeating)
WRN Your version 2026.3.0 is outdated. We recommend upgrading it to 2026.7.1

Edge connections terminate and re-register repeatedly → an SSH stream landing on a flapping connection drops mid-handshake → banner-exchange timeout. Contributing factors:

Factor Detail
Protocol quic (UDP) — sensitive to UDP path/buffer issues
UDP buffer failed to sufficiently increase receive buffer size (was 208 KiB, wanted 7168 KiB)
Version cloudflared 2026.3.0, outdated (recommended 2026.7.1)
Image tag cloudflare/cloudflared:latest — unpinned (drifts, violates pin-tags practice)
Deploy token/remote-managed tunnel (ID ad26e2ce-…); ingress in Cloudflare ZeroTrust dashboard, no local config.yml

Edited /home/mtd/cloudflared-tunnel/docker-compose.yml:

  • command: … --protocol quic … → --protocol http2 (TCP 443, no UDP → sidesteps the QUIC flap entirely)
  • image: cloudflare/cloudflared:latest → cloudflare/cloudflared:2026.7.1 (pinned)

Recreated from the metrics OOB shell with setsid docker compose up -d (see incident below).

Verification: 4 tunnel connections registered protocol=http2, precheck complete hard_fail=false; ssh cf-rilf-ha and ssh cf-rilf-gw both work (gw 2/2, no flap); conntrack (#2) still holding at ~5,110/262,144.

The first attempt ran docker compose up -d while SSH’d in via the ha-jump path, which transits the gateway. Recreating a host-net container briefly blips gateway networking → dropped my SSH → SIGHUP aborted docker compose up -d after Recreate (container left in Created state) but before Start → cloudflared never ran → all 43 tunnel routes down for ~6 min (evening, low traffic; on-site/internal access unaffected). This was an operational mistake, not a fault of http2 or the new image (which never started).

Recovery: reached the gateway over LAN via the metrics OOB path (ssh -J root@cf-rilf-metrics root@194.1.0.3, metrics has its own independent cloudflared), rolled back to quic+:latest, confirmed restore, then redid the fix correctly via the same OOB path.

  • The single gateway cloudflared serves the SSH routes for BOTH cf-rilf-ha AND cf-rilf-gw (and all rilf-shell-* except metrics) — they are not independent. Recreating it drops both simultaneously (both → websocket: bad handshake while down).
  • cf-rilf-metrics (194.1.0.15) runs its own independent cloudflared → the reliable out-of-band path when the gateway tunnel is down: ssh -o StrictHostKeyChecking=accept-new -i ~/.ssh/rilf-racksync -J root@cf-rilf-metrics root@194.1.0.3.
  • Error-type tells origin health: websocket: bad handshake = dead tunnel origin; Host key verification failed = origin reachable, only a local known_hosts miss.
  • Switch protocol to http2; pin image to 2026.7.1
  • Verify end-to-end (ha+gw SSH, http2 registration, conntrack unaffected)
  • RULE: recreate the gateway cloudflared only from the metrics OOB shell, and use setsid docker compose up -d so a session drop cannot abort it mid-operation.
  • Rollback: restore /home/mtd/cloudflared-tunnel/docker-compose.yml.bak-20260710-195326 (old quic + :latest/2026.3.0) → docker compose up -d from the metrics OOB shell.
  • Harmless leftover: UDP receive-buffer startup warning — a QUIC check, irrelevant on http2 (http2 = TCP). If ever reverting to quic, first raise net.core.rmem_max / wmem_max to ~7 MiB.
  • Watch http2 stability over the coming weeks; if any recurrence, revisit buffer tuning.
  • Per constitution: commit repo state before any remote change (done); gateway cloudflared changes affect all 43 tunnel routes → do them in a low-traffic window via the OOB path.
  • Related: #2 (conntrack — separate root cause, verified still holding during this work).