Pārlūkot izejas kodu

fix(BridgeChannel): Attempt conn retries when there are remote endpoints.

Currently, the client doesn't attempt to re-establish bridge WS when the connection is closed by the remote end with a code 1001. We have noticed that Cloudflare terminates the WS with the same error code when it recycles its proxies. When that happens, client ends up not having a bridge channel which can result quality issues.
Client now tries to re-establish connection when there are remote endpoints in the call.
dev1
Jaya Allamsetty 2 gadus atpakaļ
vecāks
revīzija
df2c309658
2 mainītis faili ar 12 papildinājumiem un 6 dzēšanām
  1. 11
    5
      modules/RTC/BridgeChannel.js
  2. 1
    1
      modules/RTC/RTC.js

+ 11
- 5
modules/RTC/BridgeChannel.js Parādīt failu

@@ -21,8 +21,9 @@ export default class BridgeChannel {
21 21
      * instance.
22 22
      * @param {string} [wsUrl] WebSocket URL.
23 23
      * @param {EventEmitter} emitter the EventEmitter instance to use for event emission.
24
+     * @param {JitsiConference} conference the conference instance.
24 25
      */
25
-    constructor(peerconnection, wsUrl, emitter) {
26
+    constructor(peerconnection, wsUrl, emitter, conference) {
26 27
         if (!peerconnection && !wsUrl) {
27 28
             throw new TypeError('At least peerconnection or wsUrl must be given');
28 29
         } else if (peerconnection && wsUrl) {
@@ -39,6 +40,9 @@ export default class BridgeChannel {
39 40
         // @type {RTCDataChannel|WebSocket}
40 41
         this._channel = null;
41 42
 
43
+        // The conference that uses this bridge channel.
44
+        this._conference = conference;
45
+
42 46
         // Whether the channel is connected or not. It will start as undefined
43 47
         // for the first connection attempt. Then transition to either true or false.
44 48
         this._connected = undefined;
@@ -377,10 +381,12 @@ export default class BridgeChannel {
377 381
                 return;
378 382
             }
379 383
 
380
-            // When the JVB closes the connection gracefully due to the participant being alone in
381
-            // the meeting it uses code 1001, so treat that as a graceful close and don't say
382
-            // anything.
383
-            const isGracefulClose = this._closedFromClient || event.code === 1001;
384
+            // When the JVB closes the connection gracefully due to the participant being alone in the meeting it uses
385
+            // code 1001. However, the same code is also used by Cloudflare when it terminates the ws. Therefore, check
386
+            // for the number of remote participants in the call and abort retries only when the endpoint is the only
387
+            // endpoint in the call.
388
+            const isGracefulClose = this._closedFromClient
389
+                || (event.code === 1001 && this._conference.getParticipantCount() === 1);
384 390
 
385 391
             if (!isGracefulClose) {
386 392
                 const { code, reason } = event;

+ 1
- 1
modules/RTC/RTC.js Parādīt failu

@@ -193,7 +193,7 @@ export default class RTC extends Listenable {
193 193
      * @param {string} [wsUrl] WebSocket URL.
194 194
      */
195 195
     initializeBridgeChannel(peerconnection, wsUrl) {
196
-        this._channel = new BridgeChannel(peerconnection, wsUrl, this.eventEmitter);
196
+        this._channel = new BridgeChannel(peerconnection, wsUrl, this.eventEmitter, this.conference);
197 197
 
198 198
         this._channelOpenListener = () => {
199 199
             const logError = (error, msgType, value) => {

Notiek ielāde…
Atcelt
Saglabāt