From e9ce80a3aa5d56e7d2aa8ad564dbaabc91c5d5d0 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 9 Aug 2020 23:25:27 -0700 Subject: [PATCH] fixes: Case where websocket will not reconnect closes #1384 --- app/components/SocketProvider.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/components/SocketProvider.js b/app/components/SocketProvider.js index 4d2c6b74..6ffecf0a 100644 --- a/app/components/SocketProvider.js +++ b/app/components/SocketProvider.js @@ -61,10 +61,16 @@ class SocketProvider extends React.Component { }); }); - this.socket.on("disconnect", () => { + this.socket.on("disconnect", (reason: string) => { // when the socket is disconnected we need to clear all presence state as // it's no longer reliable. presence.clear(); + + if (reason === "io server disconnect") { + // the disconnection was initiated by the server, need to reconnect + // manually, else the socket will automatically try to reconnect + this.socket.connect(); + } }); this.socket.on("authenticated", () => {