diff --git a/lib/socket.js b/lib/socket.js index 1dd11e2ec..e837d4b34 100644 --- a/lib/socket.js +++ b/lib/socket.js @@ -160,6 +160,12 @@ complete(xhr.responseText); } else if (xhr.status == 403) { self.onError(xhr.responseText); + } else if (xhr.status == 0) { + var errorObj = {}; + errorObj.advice = 'tryConnect'; + errorObj.reason = "XHR status: 0. Will try to connect again.."; + self.connecting = false; + !self.reconnecting && self.onError(errorObj); } else { self.connecting = false; !self.reconnecting && self.onError(xhr.responseText); @@ -456,7 +462,11 @@ if (this.options.reconnect) { this.reconnect(); } - } + }else if (err.advice === 'tryConnect' && !this.connected && !this.connecting) { + if (this.options.reconnect) { + this.reconnect(); + } + } } this.publish('error', err && err.reason ? err.reason : err);