From ed32c71d90064b0537fb8753b0d709dbd94788c7 Mon Sep 17 00:00:00 2001 From: bmcool Date: Sat, 2 Sep 2017 00:47:27 +0800 Subject: [PATCH] Fixed: some device will get error code [1006] when handshake if protocols is undefined. (#691) --- channels/static/channels/js/websocketbridge.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/channels/static/channels/js/websocketbridge.js b/channels/static/channels/js/websocketbridge.js index d7b2845..dd4af1a 100644 --- a/channels/static/channels/js/websocketbridge.js +++ b/channels/static/channels/js/websocketbridge.js @@ -115,7 +115,12 @@ var ReconnectingWebsocket = function (url, protocols, options) { var connect = function () { log('connect'); var oldWs = ws; - ws = new config.constructor(url, protocols); + if (protocols === undefined) { + ws = new config.constructor(url); + } else { + ws = new config.constructor(url, protocols); + } + connectingTimeout = setTimeout(function () { log('timeout'); ws.close();