From 87399d1064a35efc37cc81f3ddc22205baf0bf68 Mon Sep 17 00:00:00 2001 From: Alex <33497058+bexsoft@users.noreply.github.com> Date: Mon, 23 Jan 2023 20:43:52 -0600 Subject: [PATCH] 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 --- .../Console/Buckets/BucketDetails/BrowserHandler.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/portal-ui/src/screens/Console/Buckets/BucketDetails/BrowserHandler.tsx b/portal-ui/src/screens/Console/Buckets/BucketDetails/BrowserHandler.tsx index 537d86f34..e6ec86715 100644 --- a/portal-ui/src/screens/Console/Buckets/BucketDetails/BrowserHandler.tsx +++ b/portal-ui/src/screens/Console/Buckets/BucketDetails/BrowserHandler.tsx @@ -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 }; };