From 36f536fa9d72c6e560edc7b744b0c09e54fb2655 Mon Sep 17 00:00:00 2001 From: Luke Policinski Date: Wed, 2 Sep 2020 11:40:15 -0400 Subject: [PATCH] fixing an issue where ws could throw an error, and not be caught correctly --- src/paho-mqtt.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/paho-mqtt.js b/src/paho-mqtt.js index 9ca3d37..33b1efa 100644 --- a/src/paho-mqtt.js +++ b/src/paho-mqtt.js @@ -1574,10 +1574,12 @@ function onMessageArrived(message) { // Cancel all socket callbacks so that they cannot be driven again by this socket. this.socket.onopen = null; this.socket.onmessage = null; - this.socket.onerror = null; this.socket.onclose = null; - if (this.socket.readyState === 1) + if (this.socket.readyState <= 1) { + this.socket.onerror = () => {}; this.socket.close(); + } + this.socket.onerror = null; delete this.socket; }