From 8fd5143f9961e51727261e206e15a693e117148e Mon Sep 17 00:00:00 2001 From: AlexandreRouma Date: Wed, 5 Nov 2025 03:24:28 -0500 Subject: [PATCH] add heartbeat to fix connection closing when idle --- user.go | 3 +++ www/scripts/user.js | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/user.go b/user.go index 7e1a5b7..91cda48 100644 --- a/user.go +++ b/user.go @@ -223,6 +223,9 @@ func userHandler(sock *websocket.Conn) { // Release the user's display pointer user.displayMtx.Unlock(); + case "hb": + // Nothing to do, just a heart beat... + default: // Give up break; diff --git a/www/scripts/user.js b/www/scripts/user.js index 0924dea..5a3fb71 100644 --- a/www/scripts/user.js +++ b/www/scripts/user.js @@ -74,6 +74,13 @@ class WisCastUserAPIClient { dispID: dispID, otp: OTP })) + + // Send a heart-beat message every 30 seconds + setInterval(async () => { + await this.#sock.send(JSON.stringify({ + type: 'hb', + })) + }, 30000); }); }