From fe632b1a1b42876063f1fed17f5e089e685b5e3e Mon Sep 17 00:00:00 2001 From: Peter Stockings Date: Thu, 26 Jan 2023 17:19:25 +1100 Subject: [PATCH] Attempt to fix worker timeout issue by forcing reconnect client side --- static/js/BLE.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/static/js/BLE.js b/static/js/BLE.js index 7688024..2f580e2 100644 --- a/static/js/BLE.js +++ b/static/js/BLE.js @@ -24,7 +24,12 @@ async function connect(props) { console.log("> Notifications started"); characteristic.addEventListener("characteristicvaluechanged", props.onChange); console.log("> Characteristic value changed event listener added"); - socket = io(); + socket = io({ + reconnection: true, + reconnectionDelay: 1000, + reconnectionAttempts: 20, + forceNew: true, + }); socket.on("connect", () => { btn.classList.remove("bg-red-600"); @@ -82,8 +87,8 @@ function parseCSC(e) { console.log("CSC", res); if (prevRes) { let rpm = revsToRPM(prevRes, res); - if (rpm > 0) - socket.emit("message", { rpm: parseFloat(rpm.toFixed(2)), id: 1 }); + //if (rpm > 0) + socket.emit("message", { rpm: parseFloat(rpm.toFixed(2)), id: 1 }); } prevRes = res; return res;