From 79179746a748b24c7295b413f34b6df50a7a2f3b Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Wed, 9 Dec 2020 20:40:22 +0100 Subject: [PATCH] Fixed websocket reconnection logic --- platypush/backend/http/webapp/src/Events.vue | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/platypush/backend/http/webapp/src/Events.vue b/platypush/backend/http/webapp/src/Events.vue index 080ab9067..90586c580 100644 --- a/platypush/backend/http/webapp/src/Events.vue +++ b/platypush/backend/http/webapp/src/Events.vue @@ -28,12 +28,12 @@ export default { methods: { onWebsocketTimeout() { - return function() { - console.log('Websocket reconnection timed out, retrying') - this.pending = false - this.close() - this.onclose() - } + console.log('Websocket reconnection timed out, retrying') + this.pending = false + if (this.ws) + this.ws.close() + + this.onClose() }, onMessage(event) { @@ -74,8 +74,10 @@ export default { onOpen() { if (this.opened) { console.log("There's already an opened websocket connection, closing the newly opened one") - this.onclose = () => {} - this.close() + if (this.ws) { + this.ws.onclose = () => {} + this.ws.close() + } } console.log('Websocket connection successful')