Always reconnect the socket except when there is an error
Turns out we can get ABNORMAL_CODE (1006) for disconnects where (for instance) we pause the background page too long. However, in these cases there is no preceeding ErrorEvent. In contrast, when we have bad authentication credentials, there is an ErrorEvent. Thus, this change ensures that we only reconnect if there was no Error.
This commit is contained in:
@@ -15915,6 +15915,7 @@ window.axolotl.sessions = {
|
||||
onerror : function() {},
|
||||
getStatus : function() { return socket.readyState; }
|
||||
};
|
||||
var error;
|
||||
|
||||
function resetKeepAliveTimer() {
|
||||
clearTimeout(keepAliveTimer);
|
||||
@@ -15933,16 +15934,19 @@ window.axolotl.sessions = {
|
||||
};
|
||||
|
||||
function onclose(e) {
|
||||
if (e.code === 1000) { // CLOSE_NORMAL
|
||||
if (!error) {
|
||||
reconnectSemaphore--;
|
||||
setTimeout(connect, reconnectTimeout);
|
||||
} else {
|
||||
}
|
||||
if (e !== 1000 ) { // CLOSE_NORMAL
|
||||
console.log('websocket closed', e.code);
|
||||
}
|
||||
socketWrapper.onclose(e);
|
||||
};
|
||||
|
||||
function onerror(e) {
|
||||
error = e;
|
||||
console.log('websocket error');
|
||||
socketWrapper.onerror(e);
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user