# Restart WebSocket server

After the Phase 1/5 changes, the WebSocket server needs to be restarted so it
re-reads `.env` (new `JWT_SECRET`/`AGENT_API_KEY`) and reloads
`src/WsSignaling.php` (constant-time agent key check, `audio_data` size cap).

Per the operator memory note, `ws-server.php` is **not** managed by systemd.
Restart manually via SSH on the Pi:

```bash
ssh pi 'sudo pkill -f ws-server.php; sleep 1; cd /var/www/html/WebRTC && nohup php ws-server.php >> /var/log/streamcam-ws.log 2>&1 &'
```

Verify:

```bash
ssh pi 'ps aux | grep [w]s-server'
ssh pi 'ss -tlnp | grep 8081'
```

You should see a single `php ws-server.php` process owned by root or
`www-data`, listening on port 8081.

If the new `AGENT_API_KEY` isn't propagated to the iOS/Mac apps yet, agents
will fail to authenticate after this restart with `unauthorized` errors —
rebuild and reinstall both apps before going live with the new key.
