Skip to content

Commit 0e62818

Browse files
authored
fix(lobby): Handles race on joining and disabling lobby. (#2950)
* fix(lobby): Handles race on joining and disabling lobby. If a participant tries to join a lobby becuase it was enabled, but it was just disabled a room creation restriction error is received. For lobby rooms, this will retry joining the main room.
1 parent ffcffaa commit 0e62818

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

modules/xmpp/ChatRoom.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export interface IChatRoomOptions {
6565
deploymentInfo?: any;
6666
disableDiscoInfo?: boolean;
6767
disableFocus?: boolean;
68+
disableRoomCreationRetry?: boolean;
6869
enableLobby?: boolean;
6970
hiddenDomain?: string;
7071
hiddenFromRecorderFeatureEnabled?: boolean;
@@ -1552,21 +1553,23 @@ export default class ChatRoom extends Listenable {
15521553
if (txt === 'Room creation is restricted') {
15531554
type = AUTH_ERROR_TYPES.ROOM_CREATION_RESTRICTION;
15541555

1555-
if (!this._roomCreationRetries) {
1556-
this._roomCreationRetries = 0;
1557-
}
1558-
this._roomCreationRetries++;
1556+
if (!this.options.disableRoomCreationRetry) {
1557+
if (!this._roomCreationRetries) {
1558+
this._roomCreationRetries = 0;
1559+
}
1560+
this._roomCreationRetries++;
15591561

1560-
if (this._roomCreationRetries <= 3) {
1561-
const retryDelay = getJitterDelay(
1562-
/* retry */ this._roomCreationRetries,
1563-
/* minDelay */ 500,
1564-
1.5);
1562+
if (this._roomCreationRetries <= 3) {
1563+
const retryDelay = getJitterDelay(
1564+
/* retry */ this._roomCreationRetries,
1565+
/* minDelay */ 500,
1566+
1.5);
15651567

1566-
// let's retry inviting jicofo and joining the room, retries will take between 1 and 3 seconds
1567-
setTimeout(() => this.join(this.password, this.replaceParticipant), retryDelay);
1568+
// let's retry inviting jicofo and joining the room, retries will take between 1 and 3 seconds
1569+
setTimeout(() => this.join(this.password, this.replaceParticipant), retryDelay);
15681570

1569-
return;
1571+
return;
1572+
}
15701573
}
15711574
} else if (exists(pres,
15721575
':scope>error[type="cancel"]>authentication-required[*|xmlns="http://jitsi.org/jitmeet"]')) {

modules/xmpp/Lobby.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { getLogger } from '@jitsi/logger';
22
import { $msg, Strophe } from 'strophe.js';
33

4+
import { AUTH_ERROR_TYPES } from '../../JitsiConferenceErrors';
45
import { XMPPEvents } from '../../service/xmpp/XMPPEvents';
56

67
import { handleStropheError } from './StropheErrorHandler';
@@ -255,6 +256,7 @@ export default class Lobby {
255256
customDomain,
256257
disableDiscoInfo: true,
257258
disableFocus: true,
259+
disableRoomCreationRetry: true,
258260
enableLobby: false
259261
}
260262
);
@@ -383,12 +385,22 @@ export default class Lobby {
383385
}
384386
});
385387
this.lobbyRoom.addEventListener(XMPPEvents.ROOM_JOIN_ERROR, reject);
386-
this.lobbyRoom.addEventListener(XMPPEvents.ROOM_CONNECT_NOT_ALLOWED_ERROR, reject);
387388
this.lobbyRoom.addEventListener(XMPPEvents.ROOM_CONNECT_ERROR, reject);
389+
this.lobbyRoom.addEventListener(XMPPEvents.ROOM_CONNECT_NOT_ALLOWED_ERROR, (type, txt) => {
390+
if (type === AUTH_ERROR_TYPES.ROOM_CREATION_RESTRICTION) {
391+
logger.info('Lobby room creation not allowed, we will retry on main room.');
392+
this.lobbyRoom?.clean();
393+
394+
this.lobbyRoom = undefined;
395+
396+
this.mainRoom.join();
397+
} else {
398+
reject(type, txt);
399+
}
400+
});
388401

389402
this.lobbyRoom.join();
390403
});
391-
392404
}
393405

394406
/**

0 commit comments

Comments
 (0)