---
name: "No heartbeat to detect stale WebSocket connections"
---

# Bug 138: No heartbeat to detect stale WebSocket connections

## Description

The WebSocket client in frontend/src/api/client.ts only reconnects when the onclose event fires. If the connection half-closes (appears open but stops receiving data), onclose never fires and reconnection never happens. There is no ping/pong heartbeat mechanism to detect this state.

## How to Reproduce

1. Open the web UI and establish a WebSocket connection
2. Wait for a network disruption or half-close scenario
3. The connection appears open but stops delivering messages
4. No reconnection is attempted

## Actual Result

The frontend keeps a dead WebSocket open indefinitely with no way to detect it has stopped receiving data. UI becomes permanently stale until manual refresh.

## Expected Result

A heartbeat mechanism should detect stale connections and trigger automatic reconnection.

## Acceptance Criteria

- [ ] WebSocket client implements a periodic heartbeat/ping to detect stale connections
- [ ] Stale connections are automatically closed and reconnected
- [ ] Server responds to ping frames or implements server-side keepalive
