From 03c3dd4f2e801c5927efd15417a173eef84d0ff8 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Sun, 19 Feb 2023 21:36:36 -0800 Subject: [PATCH] Don't try to reconnect to chat forever --- web/static/js/BareRTC.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/web/static/js/BareRTC.js b/web/static/js/BareRTC.js index 417c5f3..621b1c0 100644 --- a/web/static/js/BareRTC.js +++ b/web/static/js/BareRTC.js @@ -17,6 +17,10 @@ const app = Vue.createApp({ windowFocused: true, // browser tab is active windowFocusedAt: new Date(), + // Disconnect spamming: don't retry too many times. + disconnectLimit: 8, + disconnectCount: 0, + // Website configuration provided by chat.html template. config: { channels: PublicChannels, @@ -405,6 +409,12 @@ const app = Vue.createApp({ this.ws.connected = false; this.ChatClient(`WebSocket Disconnected code: ${ev.code}, reason: ${ev.reason}`); + this.disconnectCount++; + if (this.disconnectCount > this.disconnectLimit) { + this.ChatClient(`It seems there's a problem connecting to the server. Please try some other time. Note that iPhones and iPads currently have issues connecting to the chat room in general.`); + return; + } + if (!this.disconnect) { if (ev.code !== 1001) { this.ChatClient("Reconnecting in 5s");