diff --git a/node_common/managers/viewer.js b/node_common/managers/viewer.js index 0a44f270..4ac0384d 100644 --- a/node_common/managers/viewer.js +++ b/node_common/managers/viewer.js @@ -22,7 +22,9 @@ const websocketSend = async (type, data) => { let ws = Websocket.get(); if (!ws) { console.log("no websocket. creating now..."); + //set a timeout so it won't proceed for a few seconds after creating the socket? or maybe an wait if possible ws = Websocket.create(); + //or maybe create it and then send back a failure event so they know to try again? console.log(ws ? "Successfully created websocket" : "Failed to create websocket"); } diff --git a/node_common/nodejs-websocket.js b/node_common/nodejs-websocket.js index 46d667f3..3ce7f0f0 100644 --- a/node_common/nodejs-websocket.js +++ b/node_common/nodejs-websocket.js @@ -35,9 +35,10 @@ export const create = () => { }); ws.on("close", () => { - global.websocket = null; - console.log(global.websocket); - setTimeout(create, 1000); + setTimeout(() => { + NodeLogging.log(`Auto reconnecting websocket`); + create(); + }, 1000); NodeLogging.log(`Websocket disconnected`); });