Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"js-md5": "0.6.1",
"js-sha512": "0.8.0",
"jwt-decode": "2.2.0",
"lib-jitsi-meet": "https://github.com/internxt/lib-jitsi-meet/releases/download/v.0.0.20/lib-jitsi-meet-0.0.20.tgz",
"lib-jitsi-meet": "https://github.com/internxt/lib-jitsi-meet/releases/download/v.0.0.20-debug/lib-jitsi-meet-0.0.20-debug.tgz",
"lodash-es": "4.17.23",
"moment": "2.29.4",
"moment-duration-format": "2.2.2",
Expand Down
1 change: 1 addition & 0 deletions react/features/app/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ function _connectionEstablished(store: IStore, next: Function, action: AnyAction
* @private
*/
function _connectionFailed({ dispatch, getState }: IStore, next: Function, action: AnyAction) {
console.log("[AUTO_RECONNECT] Entered _connectionFailed to check _isMaybeSplitBrainError");
// In the case of a split-brain error, reload early and prevent further
// handling of the action.
if (_isMaybeSplitBrainError(getState, action)) {
Expand Down
1 change: 1 addition & 0 deletions react/features/authentication/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ MiddlewareRegistry.register(store => next => action => {
break;

case CONNECTION_FAILED: {
console.log("[AUTO_RECONNECT] Entered CONNECTION_FAILED to check jwt");
const { error } = action;
const { getState } = store;
const state = getState();
Expand Down
1 change: 1 addition & 0 deletions react/features/base/conference/middleware.any.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ function _logJwtErrors(message: string, errors: string) {
* @returns {Object} The value returned by {@code next(action)}.
*/
function _connectionFailed({ dispatch, getState }: IStore, next: Function, action: AnyAction) {
console.log("[AUTO_RECONNECT] Entered _connectionFailed to maybe send conferenceFailed");
const { connection, error } = action;
const { jwt } = getState()['features/base/jwt'];

Expand Down
3 changes: 3 additions & 0 deletions react/features/base/connection/actions.any.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { JITSI_CONNECTION_URL_KEY } from "./constants";
import logger from "./logger";
import { get8x8Options } from "./options8x8";
import { ConnectionFailedError, IIceServers } from "./types";
import { log } from '@tensorflow/tfjs-core/dist/log';

/**
* The options that will be passed to the JitsiConnection instance.
Expand Down Expand Up @@ -94,6 +95,7 @@ export function connectionEstablished(connection: Object, timeEstablished: numbe
* }}
*/
export function connectionFailed(connection: Object, error: ConnectionFailedError) {
console.log("[AUTO_RECONNECT] CconnectionFailed return CONNECTION_FAILED action");
const { credentials } = error;

if (credentials && !Object.keys(credentials).length) {
Expand Down Expand Up @@ -311,6 +313,7 @@ export function _connectInternal({
* @returns {void}
*/
function _onConnectionFailed(err: string, message: string, credentials: any, details: Object) {
console.log("[AUTO_RECONNECT] send CONNECTION_FAILED notification");
// eslint-disable-line max-params
unsubscribe();

Expand Down
1 change: 1 addition & 0 deletions react/features/base/connection/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ function _connectionFailed(
connection: Object;
error: ConnectionFailedError;
}) {
console.log("[AUTO_RECONNECT] Entered _connectionFailed of reducer");
const connection_ = _getCurrentConnection(state);

if (connection_ && connection_ !== connection) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ export const setupXMPPConnectionListeners = (connection: any, dispatch: IStore["
handleXMPPDisconnected(dispatch, message)
);

connection.addEventListener(JitsiConnectionEvents.CONNECTION_FAILED, (error: any, message: string) =>
handleXMPPConnectionFailed(dispatch, error, message)
connection.addEventListener(JitsiConnectionEvents.CONNECTION_FAILED, (error: any, message: string) => {
console.log("[AUTO_RECONNECT] dispatched CONNECTION_FAILED from XMPP connection listener");
handleXMPPConnectionFailed(dispatch, error, message);
}
);

state.hasConnectionListeners = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,28 @@ import { hideLoader, showLoader } from "../../loader";
const RECONNECTION_NOTIFICATION_ID = "connection.reconnecting";
const RECONNECTION_LOADER_ID = "auto-reconnect";
const RECONNECTION_WAIT_TIME_MS = 15000;
const MAX_RECONNECTION_ATTEMPTS = 2;
const RECONNECTION_DELAY_MS = 3000;
const JWT_EXPIRED_ERROR = "connection.passwordRequired";

let reconnectionTimer: number | null = null;
let isReconnecting = false;
let reconnectionAttempts = 0;

export const isAutoReconnecting = () => isReconnecting;

const hideReconnectionNotification = (store: IStore) => {
store.dispatch(hideNotification(RECONNECTION_NOTIFICATION_ID));
};

const showReconnectionLoader = (store: IStore, attempt: number) => {
const textKey = attempt <= MAX_RECONNECTION_ATTEMPTS ? "loader.reconnecting" : "loader.reloading";
const showReconnectionLoader = (store: IStore) => {

store.dispatch(showLoader(undefined, textKey, RECONNECTION_LOADER_ID));
store.dispatch(showLoader(undefined, "loader.reconnecting", RECONNECTION_LOADER_ID));
};

const hideReconnectionLoader = (store: IStore) => {
store.dispatch(hideLoader(RECONNECTION_LOADER_ID));
};

const reloadPage = () => {
window.location.reload();
};


const clearExpiredJWT = (store: IStore) => {
store.dispatch(setJWT(undefined));
Expand Down Expand Up @@ -69,27 +64,15 @@ const scheduleRetry = (store: IStore) => {
}, RECONNECTION_DELAY_MS);
};

const handleMaxAttemptsReached = (store: IStore) => {
isReconnecting = true;
showReconnectionLoader(store, reconnectionAttempts + 1);
reconnectionTimer = window.setTimeout(reloadPage, 2000);
};

/**
* Attempts to reconnect by clearing JWT and connecting to conference again.
* If max attempts reached, reloads the page.
*/
const attemptReconnection = async (store: IStore) => {
if (isLeavingConferenceManually()) return;

if (reconnectionAttempts >= MAX_RECONNECTION_ATTEMPTS) {
handleMaxAttemptsReached(store);
return;
}

reconnectionAttempts++;
isReconnecting = true;
showReconnectionLoader(store, reconnectionAttempts);
showReconnectionLoader(store);

try {
clearRemoteTracks(store);
Expand All @@ -112,7 +95,6 @@ const clearTimer = () => {

const resetReconnectionState = () => {
clearTimer();
reconnectionAttempts = 0;
isReconnecting = false;
};

Expand All @@ -135,7 +117,6 @@ MiddlewareRegistry.register((store: IStore) => (next: Function) => (action: AnyA
if (isLeavingConferenceManually()) break;

clearTimer();
reconnectionAttempts = 0;
isReconnecting = true;

reconnectionTimer = window.setTimeout(() => {
Expand All @@ -159,8 +140,8 @@ MiddlewareRegistry.register((store: IStore) => (next: Function) => (action: AnyA
}

case CONNECTION_FAILED: {
console.log("[AUTO_RECONNECT] Attempting reconnect");
const { error } = action;
console.log("[AUTO_RECONNECT] Connection failed with error:", error);
if (error?.name === JWT_EXPIRED_ERROR && !isLeavingConferenceManually() && !isReconnecting) {
attemptReconnection(store);
}
Expand Down
1 change: 1 addition & 0 deletions react/features/prejoin/middleware.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ MiddlewareRegistry.register(store => next => action => {
}
case CONFERENCE_FAILED:
case CONNECTION_FAILED:
console.log("[AUTO_RECONNECT] set setJoiningInProgress to false in middleware");
store.dispatch(setJoiningInProgress(false));
break;
case CONFERENCE_JOINED:
Expand Down
1 change: 1 addition & 0 deletions react/features/visitors/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
break;
}
case CONNECTION_FAILED: {
console.log("[AUTO_RECONNECT] attempting reconnect in CONNECTION_FAILED of visitors middleware");
const { error } = action;

if (error?.name !== JitsiConnectionErrors.NOT_LIVE_ERROR) {
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11081,9 +11081,9 @@ levn@^0.4.1:
prelude-ls "^1.2.1"
type-check "~0.4.0"

"lib-jitsi-meet@https://github.com/internxt/lib-jitsi-meet/releases/download/v.0.0.20/lib-jitsi-meet-0.0.20.tgz":
version "0.0.20"
resolved "https://github.com/internxt/lib-jitsi-meet/releases/download/v.0.0.20/lib-jitsi-meet-0.0.20.tgz#5048eba36fa1f6b1884c00d6d5a21e847c9d2c46"
"lib-jitsi-meet@https://github.com/internxt/lib-jitsi-meet/releases/download/v.0.0.20-debug/lib-jitsi-meet-0.0.20-debug.tgz":
version "0.0.20-debug"
resolved "https://github.com/internxt/lib-jitsi-meet/releases/download/v.0.0.20-debug/lib-jitsi-meet-0.0.20-debug.tgz#3e5a6b196a215d2dc449c588c23ad32bded2b1de"
dependencies:
"@hexagon/base64" "^2.0.4"
"@jitsi/js-utils" "^2.6.7"
Expand Down