Fixed WS reconnection logic onError and onClose (#2591)

Removes duplicated reconnection request when error is reached on Object
Browser websocket, also removed the use of the connect call back as it
will contain references to the initial request and it is not necessary
as we already have information available.

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
This commit is contained in:
Alex
2023-01-23 20:43:52 -06:00
committed by GitHub
parent a01b855d2f
commit 87399d1064

View File

@@ -121,7 +121,7 @@ const initWSConnection = (
const reconnectFn = () => {
if (errorCounter <= 5) {
initWSConnection(openCallback, onMessageCallback);
initWSConnection(() => {}, onMessageCallback);
errorCounter += 1;
} else {
console.error("Websocket not available.");
@@ -139,9 +139,7 @@ const initWSConnection = (
objectsWS.onerror = () => {
wsInFlight = false;
console.error("Error in websocket connection. Attempting reconnection...");
// We reconnect after 3 seconds
setTimeout(reconnectFn, 3000);
// Onclose will be triggered by specification, reconnect function will be executed there to avoid duplicated requests
};
};