chore(config): env-configurable heartbeat timing

Make HEARTBEAT_INTERVAL and HEARTBEAT_TIMEOUT env-tunable so
self-hosters with slow/jittery networks don't have to edit
config.js (issue #3 reporter did exactly this to confirm the
diagnosis). Defaults unchanged at 10000ms / 45000ms so existing
deployments keep current behavior.

Same parseInt(env) || default pattern as PORT/HTTPS_PORT/PING_*.
README env table extended.

Refs #3

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
ScreenTinker 2026-05-14 13:03:02 -05:00
parent 1aee4f2d5b
commit 3da49ec79c
2 changed files with 8 additions and 2 deletions

View file

@ -117,6 +117,8 @@ Schema migrations run automatically on first boot — no manual migration comman
| `SSL_KEY` | Path to SSL private key | `server/certs/key.pem` | | `SSL_KEY` | Path to SSL private key | `server/certs/key.pem` |
| `PING_INTERVAL` | Socket.IO Engine.IO ping interval (ms). Raise for slow TV WebKits that miss pongs under decode load. | `30000` | | `PING_INTERVAL` | Socket.IO Engine.IO ping interval (ms). Raise for slow TV WebKits that miss pongs under decode load. | `30000` |
| `PING_TIMEOUT` | Socket.IO Engine.IO pong wait (ms). Lower = faster dead-socket detection; higher = more forgiving of laggy clients. | `30000` | | `PING_TIMEOUT` | Socket.IO Engine.IO pong wait (ms). Lower = faster dead-socket detection; higher = more forgiving of laggy clients. | `30000` |
| `HEARTBEAT_INTERVAL` | App-level offline-checker frequency (ms). How often the server sweeps the device list looking for stale heartbeats. | `10000` |
| `HEARTBEAT_TIMEOUT` | How long without an app-level heartbeat (ms) before marking a device offline. Raise for slow/jittery networks. | `45000` |
### Optional Integrations ### Optional Integrations

View file

@ -8,8 +8,12 @@ module.exports = {
contentDir: path.join(__dirname, 'uploads', 'content'), contentDir: path.join(__dirname, 'uploads', 'content'),
screenshotsDir: path.join(__dirname, 'uploads', 'screenshots'), screenshotsDir: path.join(__dirname, 'uploads', 'screenshots'),
frontendDir: path.join(__dirname, '..', 'frontend'), frontendDir: path.join(__dirname, '..', 'frontend'),
heartbeatInterval: 10000, // Check every 10s // App-level heartbeat. Checker runs every heartbeatInterval and marks
heartbeatTimeout: 45000, // Offline after 45s (3 missed 15s beats) // devices offline if last_heartbeat is older than heartbeatTimeout.
// Env override for self-hosters on slow/jittery networks (issue #3:
// reporter found raising HEARTBEAT_TIMEOUT to 60s reduced false offlines).
heartbeatInterval: parseInt(process.env.HEARTBEAT_INTERVAL) || 10000,
heartbeatTimeout: parseInt(process.env.HEARTBEAT_TIMEOUT) || 45000,
// Engine.IO transport-level ping/pong. Raised from Socket.IO defaults // Engine.IO transport-level ping/pong. Raised from Socket.IO defaults
// (25000/20000) because TV WebKits (LG webOS, older Tizen) miss pongs // (25000/20000) because TV WebKits (LG webOS, older Tizen) miss pongs
// under decode load - tighter values cause spurious transport drops. // under decode load - tighter values cause spurious transport drops.