diff --git a/lib/transports/websocket.js b/lib/transports/websocket.js index e0621e550..b52bbeef4 100644 --- a/lib/transports/websocket.js +++ b/lib/transports/websocket.js @@ -96,7 +96,11 @@ WS.prototype.doOpen = function () { opts.headers = this.extraHeaders; } - this.ws = BrowserWebSocket ? new WebSocket(uri) : new WebSocket(uri, protocols, opts); + try { + this.ws = BrowserWebSocket ? new WebSocket(uri) : new WebSocket(uri, protocols, opts); + } catch (err) { + return this.emit('error', err) + } if (this.ws.binaryType === undefined) { this.supportsBinary = false;