From 5b33219f131044ff099165a2a3827d3307585cb2 Mon Sep 17 00:00:00 2001 From: slice Date: Fri, 13 Jul 2018 19:33:53 -0700 Subject: [PATCH] show close code and reason on ws close --- priv/frontend/src/components/App.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/priv/frontend/src/components/App.js b/priv/frontend/src/components/App.js index 131a3ed..0c102b6 100644 --- a/priv/frontend/src/components/App.js +++ b/priv/frontend/src/components/App.js @@ -77,8 +77,9 @@ export default class App extends Component { this.subscribeToChannels(); }; - this.websocket.onclose = () => { - log(`ws closed; attempting to reconnect in ${this.reconnectionTime}ms`); + this.websocket.onclose = ({ code, reason }) => { + log(`ws closed with code ${code} (reason: ${reason || ''}); ` + + `attempting to reconnect in ${this.reconnectionTime}ms`); setTimeout(() => this.connect(), this.reconnectionTime); this.reconnectionTime *= 2; }; @@ -91,12 +92,11 @@ export default class App extends Component { this.handlePacket(parsed); }; - this.websocket.onerror = (error) => { - log('ws error:', error); + this.websocket.onerror = (event) => { + log('ws error:', event); }; } - _send(payload) { this.websocket.send(JSON.stringify(payload)); }