From ed9e5519f622fc288a8e01d07ad49d510a51d627 Mon Sep 17 00:00:00 2001 From: David Botton Date: Sun, 11 Feb 2024 21:16:32 -0500 Subject: [PATCH] better handle slow connections on reconnect --- static-files/js/boot.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/static-files/js/boot.js b/static-files/js/boot.js index 24b0261..4f44506 100644 --- a/static-files/js/boot.js +++ b/static-files/js/boot.js @@ -33,15 +33,12 @@ function Shutdown_ws(event) { ws = null; } clearInterval (pingerid); - clearInterval (retryid); if (clog['html_on_close'] != '') { $(document.body).html(clog['html_on_close']); } } function Setup_ws() { - clearInterval (retryid); - retryid = 0; ws.onmessage = function (event) { try { if (clog_debug == true) { @@ -55,6 +52,7 @@ function Setup_ws() { var rc = function (event) { console.log (event); + clearInterval (retryid); ws = null; ws = new WebSocket (adr + '?r=' + clog['connection_id']); ws.onopen = function (event) { @@ -64,8 +62,7 @@ function Setup_ws() { ws.onclose = function (event) { console.log ('reconnect failure'); console.log (Date.now()); - if (retryid == 0) - retryid = setInterval(function () {rc("Failed reconnect - trying again")}, 500); + retryid = setInterval(function () {rc("Failed reconnect - trying again")}, 500); } }