repo: janusweb
action: commit
revision: 
path_from: 
revision_from: c15c1c894e959f1b5950f0f2d310595b72154f91:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit c15c1c894e959f1b5950f0f2d310595b72154f91
Author: James Baicoianu 
Date:   Thu Oct 17 17:33:04 2024 -0700

    Improved server reconnection reliability

diff --git a/scripts/external/JanusClientConnection.js b/scripts/external/JanusClientConnection.js
index cd96da7d522b70dc62c79380413ba13299fbabde..
index ..78ddb6bbffbb49be92326dd8fcc37571b37bf4ed 100644
--- a/scripts/external/JanusClientConnection.js
+++ b/scripts/external/JanusClientConnection.js
@@ -336,9 +336,7 @@ JanusClientConnection.prototype.connect = function() {
   this._websocket.onclose = function() {
     this.status = 0;
     this.dispatchEvent({type: 'disconnect'});
-    if (!this.pendingReconnect) {
-      this.reconnect();
-    }
+    this.reconnect();
   }.bind(this);

   this._websocket.onmessage = this.onMessage.bind(this)  
@@ -354,6 +352,8 @@ JanusClientConnection.prototype.reconnect = function(force) {
       console.log('Reconnecting...');
       this.connect();
     }
+  } else {
+    console.log('reconnect attempted too soon', this.lastattempt, now, this.reconnectdelay);
   }
 }
 JanusClientConnection.prototype.disconnect = function() {
@@ -392,7 +392,7 @@ JanusClientConnection.prototype.setUserId = function(userId) {
 };

 JanusClientConnection.prototype.send = function(msg) {
-  if (this._websocket.readyState == 3) {
+  if (this._websocket.readyState > 1) {
     this.msgQueue.push(msg);
     if (!this.pendingReconnect) {
       this.reconnect();

-----END OF PAGE-----