[Bug] iOS: WebSocket doesn't reconnect after app foregrounding — requires force-kill to receive new messages
- Dominant language
- Rust
- Stars
- 32.7k
- Forks
- 4.3k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 253
Description
## Describe the bug
When the Buzz iOS app is backgrounded and then brought back to the foreground, the WebSocket connection to the relay is not re-established. The app appears "connected" but no new messages arrive until the user force-kills the app and reopens it, which forces a fresh connection.
## Steps to reproduce
1. Open Buzz iOS app, confirm messages are flowing
2. Background the app (swipe home) for 30+ seconds
3. Return to the app
4. Observe: no new messages appear, app appears stale
5. Force-kill the app and reopen
6. New messages immediately appear
## Expected behavior
The app should detect the stale/dead WebSocket connection on foreground (via `UIApplication.willEnterForegroundNotification` or `scenePhase` change) and automatically reconnect to the relay.
## Actual behavior
WebSocket connection appears to be left in a zombie state after iOS background suspension. No reconnection logic fires on foreground.
## Environment
- **Platform:** iOS (iPhone)
- **App version:** (latest as of 2026-08-02)
- **Relay:** `wss://maverickint.communities.buzz.xyz` (self-hosted, behind Cloudflare CDN)
- **Relay health:** Verified healthy — HTTPS 200 (100ms), WebSocket upgrade 101
- **DNS:** Resolves through Cloudflare (`communities.buzz.xyz.cdn.cloudflare.net`)
## Diagnosis (server-side ruled out)
The relay is confirmed healthy and accepting WebSocket upgrades normally. The issue is purely client-side — iOS is suspending the WebSocket on background, and the app is not detecting/reconnecting the dead socket on foreground. Standard iOS WebSocket lifecycle handling requires:
1. On `willEnterForegroundNotification`: check if socket is still alive (ping/pong or readyState check)
2. If dead or stale: tear down and re-establish connection
3. Optionally: periodic heartbeat to detect zombie connections while in background (iOS allows brief background tasks for this)
## Additional context
- This may be related to iOS's aggressive socket suspension policy (connections are killed after ~30s in background)
- The behavior is consistent — happens every time after backgrounding for more than ~30 seconds
- No error messages are shown to the user; the app just silently stops receiving messages
Contributor guide
Assessment
This issue has not been assessed yet.