aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-01-07 19:16:25 -0600
committerIván Ávalos <avalos@disroot.org>2022-01-07 19:16:25 -0600
commitaf914cebb36ecb1207681255bd1adbab0481e149 (patch)
tree16ce1db11a74634b654648acb82d37ab1b2dec58
parent324585ae83ad1802ed3903a1e7fdab81707ed1b7 (diff)
downloadetbsa-traccar-web-af914cebb36ecb1207681255bd1adbab0481e149.tar.gz
etbsa-traccar-web-af914cebb36ecb1207681255bd1adbab0481e149.tar.bz2
etbsa-traccar-web-af914cebb36ecb1207681255bd1adbab0481e149.zip
Automatically reconnect web socket
-rw-r--r--modern/src/SocketController.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/modern/src/SocketController.js b/modern/src/SocketController.js
index 7718db8..07faae0 100644
--- a/modern/src/SocketController.js
+++ b/modern/src/SocketController.js
@@ -53,6 +53,13 @@ const SocketController = () => {
displayNotifications(data.events, t);
}
};
+
+ socket.onclose = () => {
+ console.log ('Socket is closed, reconnecting…');
+ setTimeout(() => {
+ connectSocket();
+ }, 1000);
+ };
};
useEffectAsync(async () => {