From 3111f3b8ac470bad36b9e4a2445834d0b3c62f97 Mon Sep 17 00:00:00 2001 From: Flavio Curella Date: Tue, 12 Sep 2017 10:22:24 -0700 Subject: [PATCH] Fix error code [1006] if protocols is `undefined` (#735) --- channels/static/channels/js/websocketbridge.js | 5 ++++- js_client/lib/index.js | 3 ++- js_client/src/index.js | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/channels/static/channels/js/websocketbridge.js b/channels/static/channels/js/websocketbridge.js index d7b2845..e5650e4 100644 --- a/channels/static/channels/js/websocketbridge.js +++ b/channels/static/channels/js/websocketbridge.js @@ -283,7 +283,10 @@ var WebSocketBridge = function () { _url = url; } } - this.socket = new _reconnectingWebsocket2.default(_url, protocols, options); + // Some mobile devices (eg: HTC M8, SAMSUNG Galaxy S8) will get error code + // [1006] during handshake if `protocols` is `undefined`. + var _protocols = protocols === undefined ? '' : protocols; + this.socket = new _reconnectingWebsocket2.default(_url, _protocols, options); } /** diff --git a/js_client/lib/index.js b/js_client/lib/index.js index 53ca4f0..0e69313 100644 --- a/js_client/lib/index.js +++ b/js_client/lib/index.js @@ -72,7 +72,8 @@ var WebSocketBridge = function () { _url = url; } } - this.socket = new _reconnectingWebsocket2.default(_url, protocols, options); + var _protocols = protocols === undefined ? '' : protocols; + this.socket = new _reconnectingWebsocket2.default(_url, _protocols, options); } /** diff --git a/js_client/src/index.js b/js_client/src/index.js index b2ebd81..ae0fd48 100644 --- a/js_client/src/index.js +++ b/js_client/src/index.js @@ -50,7 +50,10 @@ export class WebSocketBridge { _url = url; } } - this.socket = new ReconnectingWebSocket(_url, protocols, options); + // Some mobile devices (eg: HTC M8, SAMSUNG Galaxy S8) will get error code + // [1006] during handshake if `protocols` is `undefined`. + const _protocols = protocols === undefined ? '' : protocols; + this.socket = new ReconnectingWebSocket(_url, _protocols, options); } /**