Skip to content

iOS app shows "Reconnecting…" after returning from background when the environment is a headless Linux server reached through T3 Connect #31829

Open

Description

@murdochmurch

What happened

Every time I leave the iOS app and come back, it shows "Reconnecting to …" for a while before the thread is usable. This happens with my always-on headless Linux VM (background service, T3 Connect managed tunnel). It does not happen with my Mac environment. It happens on small threads too, so it is not thread size.

Diagnosis

Server traces show the iOS websocket (clientSurface=mobile, via the managed relay host) is never closed by the server or relay after iOS suspends the app. Each mobile session ends at the exact moment the next one opens (0-4 s apart), i.e. the server only learns the old socket is dead when the phone reconnects. So on return the app waits on a dead socket until its own timeout, then reconnects; the server answers the new connection within about a second. Looks like there is no heartbeat/idle detection on the mobile <-> relay <-> server websocket, or the app does not reconnect immediately on foreground. The tunnel itself is healthy the whole time (4 QUIC connections, reachable). Box is idle (load 0.2, 26 GB free).

Steps to reproduce

  1. Run T3 as the background service on a headless Linux host with T3 Connect (managed tunnel).
  2. Open any thread on that environment in the iOS app.
  3. Switch away from the app for about a minute, then return.
  4. The app shows "Reconnecting to …" before it is usable. The same steps against a Mac environment reconnect without the delay.

Version

Server 0.1.8-nightly.20261106.4247 (background service); iOS app version: not recorded

Environment

Ubuntu 24.04.5 LTS (Azure VM, kernel 7.0.0-1017-azure), T3 Connect managed tunnel via managed cloudflared 2026.10.4 (QUIC), iOS app

Evidence

Mobile websocket sessions from server.trace.ndjson (GET /ws, clientSurface=mobile, via <managed-relay-host>), UTC:
04:17:12 -> 04:34:53  next opens 04:34:57
04:34:57 -> 04:37:31  next opens 04:37:32
04:37:32 -> 04:49:20
04:51:46 -> 05:02:15  next opens 05:02:16
05:02:16 -> 05:09:40  next opens 05:09:40
05:09:40 -> 05:14:09

t3 connect status: authenticated, linked, publishAgentActivity true, relayClient available (managed cloudflared 2026.10.4), reachability reachable, readyConnections 4, protocol quic.
Only relay warnings: cloudflared ICMP proxy disabled (GID not in ping_group_range), unrelated.

Related issues

Searched for reconnecting/stale websocket/mobile reconnect: no match. #31534 is about Live Activities in publish-only Tailscale mode, a different problem.

Fix applied or workaround

None. Nothing changed on the machine.

Filed by

claude (claude-opus-5-5) via Claude Code, following the t3 triage playbook manually

Activity

  1. juliusmarminge commented on Nov 6, 2026

    @juliusmarminge
    Member

    Checked against main at 6f54322e4a.

    The app already handles a socket that iOS kills while the app is suspended. If the app was in the background for 10 s or more, coming back checks the open socket first. When the host answers a fresh request but the socket stays silent, the app replaces the socket after 0.5 s, or after 1.5 s at most if that host check stalls too. The client tests for this path pass in packages/client-runtime/src/connection/supervisor.test.ts, including replaces a silent remote socket without the wait after a long resume, which runs on a T3 Connect route. This logic runs in the iOS app, not the server (#25824, tightened in #28487), so the server version doesn't settle which behaviour you have.

    The server seeing the old socket end only when the next one opens is expected. The phone closes the dead socket as it replaces it. A server-side heartbeat would only tell the server sooner. It wouldn't shorten the wait on the phone.

    Once the socket is replaced, the app builds a new connection through T3 Connect and shows "Reconnecting to …" until it has synced. A LAN or Tailscale route reaches the host over a much shorter path, so the same reconnect usually finishes before you notice it. To tell whether you're seeing that reconnect or something slower, could you add:

    1. The iOS app version (Settings › About › Version).
    2. About how many seconds "Reconnecting to …" stays on screen.
    3. How the Mac environment is connected in the app: through T3 Connect as well, or over LAN/Tailscale.
    4. If the notice ever shows a trace ID, that ID.
  2. shivamhwp commented on Nov 6, 2026

    @shivamhwp
    Collaborator

    [GPT-6.1 Sol][Codex] on behalf of shivam.

    I tested main at 2e39f1d7dec44c98a4cabdaf99d3d99209f770c0 with T3 Code Dev 2.2.0 build 1 on an iOS 27.0 simulator against an isolated headless Ubuntu server. After about 93 seconds in the background, the thread returned without a prolonged reconnect notice and accepted another message. The recording includes the return at about 1:48 and the successful reply.

    This used a direct tailnet connection, not managed T3 Connect. The same WebSocket survived the background interval, so it did not exercise replacement of a dead native socket. Managed relay behavior and the production iPhone build remain unverified. Existing tests passed at that commit: 62 in packages/client-runtime/src/connection/supervisor.test.ts and 1 in apps/mobile/src/lib/foreground-handoff.test.ts.

    Could you add a short recording of the delay and its timestamp with timezone, alongside the app version/build, approximate delay, Mac connection route and any trace ID Julius requested? That will help distinguish the initial socket recovery from route setup or sync. Please exclude pairing links, tokens and private thread content. No fix or PR yet; the direct result does not rule out your managed-route report.

    linux-direct-background-review.mp4
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions