diff --git a/priv/frontend/src/components/App.js b/priv/frontend/src/components/App.js index 4f3718e..131a3ed 100644 --- a/priv/frontend/src/components/App.js +++ b/priv/frontend/src/components/App.js @@ -12,6 +12,8 @@ const DOMAIN = 'https://elstatus.stayathomeserver.club'; export default class App extends Component { websocket = null; + reconnectionTime = 1000; + state = { loading: true, error: null, @@ -75,6 +77,12 @@ export default class App extends Component { this.subscribeToChannels(); }; + this.websocket.onclose = () => { + log(`ws closed; attempting to reconnect in ${this.reconnectionTime}ms`); + setTimeout(() => this.connect(), this.reconnectionTime); + this.reconnectionTime *= 2; + }; + this.websocket.onmessage = (message) => { const { data } = message; const parsed = JSON.parse(data);