From 9591c7e51a704bdd9ed404007cac4e10004f514a Mon Sep 17 00:00:00 2001 From: Amateur Audio Dude <168192910+AmateurAudioDude@users.noreply.github.com> Date: Tue, 1 Oct 2024 16:34:42 +1000 Subject: [PATCH] More solutions for WS reconnect on unstable connection --- web/js/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/js/main.js b/web/js/main.js index 17e107e..22bb828 100644 --- a/web/js/main.js +++ b/web/js/main.js @@ -291,7 +291,7 @@ function sendPingRequest() { $('#current-ping').text(`Ping: unknown`); if (!pingTimeLimit) { // Force reconnection as WebSocket could be unresponsive even though it's reported as OPEN window.socket.close(1000, 'Normal closure'); - sendToast('warning', 'Connection lost', 'Attempting to reconnect...', false, false); + if (connectionLost) sendToast('warning', 'Connection lost', 'Attempting to reconnect...', false, false); console.log("Reconnecting due to high ping..."); pingTimeLimit = true; } @@ -311,7 +311,7 @@ function sendPingRequest() { if (messageCounter === 5) { messageCounter = 0; window.socket.close(1000, 'Normal closure'); - sendToast('warning', 'Connection lost', 'Attempting to reconnect...', false, false); + if (connectionLost) sendToast('warning', 'Connection lost', 'Attempting to reconnect...', false, false); console.log("Reconnecting due to no data received..."); } } else {