diff --git a/js/libtextsecure.js b/js/libtextsecure.js index b02aa93fd..99235a531 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -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); }; diff --git a/libtextsecure/websocket.js b/libtextsecure/websocket.js index f97233e8d..df134e9e1 100644 --- a/libtextsecure/websocket.js +++ b/libtextsecure/websocket.js @@ -35,6 +35,7 @@ onerror : function() {}, getStatus : function() { return socket.readyState; } }; + var error; function resetKeepAliveTimer() { clearTimeout(keepAliveTimer); @@ -53,16 +54,19 @@ }; 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); };