From ff8c09141c66cd9713a608db34898b1abfb8c74a Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 22 Sep 2022 15:52:46 +0100 Subject: [PATCH] Reduce websocket polling frequency and cap reconnection attemps --- packages/client/src/websocket.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/client/src/websocket.js b/packages/client/src/websocket.js index b9f9668fde..827453fad6 100644 --- a/packages/client/src/websocket.js +++ b/packages/client/src/websocket.js @@ -18,6 +18,14 @@ export const initWebsocket = () => { const port = location.port || (tls ? 443 : 80) const socket = io(`${proto}//${host}:${port}`, { path: "/socket/client", + // Cap reconnection attempts to 10 (total of 95 seconds before giving up) + reconnectionAttempts: 10, + // Delay initial reconnection attempt by 5 seconds + reconnectionDelay: 5000, + // Then decrease to 10 second intervals + reconnectionDelayMax: 10000, + // Timeout after 5 seconds so we never stack requests + timeout: 5000, }) // Event handlers