Skip to content

Commit 0d2e5fe

Browse files
committed
fix(strophe) Add a strophe error handler, send errors to RTCStats.
1 parent 8953668 commit 0d2e5fe

File tree

12 files changed

+619
-24
lines changed

12 files changed

+619
-24
lines changed

modules/RTCStats/RTCStatsEvents.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ export enum RTCStatsEvents {
8484
*/
8585
STROPHE_DISCONNECTED_EVENT = 'stropheDisconnected',
8686

87+
/**
88+
* Event that indicates that a strophe error has occurred.
89+
*
90+
* @param {object} data - The data.
91+
*/
92+
STROPHE_ERROR_EVENT = 'strophe.error',
93+
8794
/**
8895
* Event that indicates that the strophe connection has been re-established.
8996
*/

modules/recording/JibriSession.ts

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

44
import JitsiParticipant from '../../JitsiParticipant';
5+
import { handleStropheError } from '../xmpp/StropheErrorHandler';
56
import XmppConnection from '../xmpp/XmppConnection';
67

78
import { getSessionIdFromIq } from './recordingXMLUtils';
@@ -244,6 +245,10 @@ export default class JibriSession {
244245
},
245246
(error: any) => {
246247
this._setErrorFromIq(error);
248+
handleStropheError(error, {
249+
operation: 'start Jibri session request',
250+
userJid: this._connection?.jid,
251+
});
247252

248253
reject(error);
249254
}
@@ -268,7 +273,13 @@ export default class JibriSession {
268273
focusMucJid
269274
}),
270275
resolve,
271-
reject
276+
(error: any) => {
277+
handleStropheError(error, {
278+
operation: 'stop Jibri session request',
279+
userJid: this._connection?.jid
280+
});
281+
reject(error);
282+
}
272283
);
273284
});
274285
}

modules/videosipgw/JitsiVideoSIPGWSession.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { $iq } from 'strophe.js';
33

44
import Listenable from '../util/Listenable';
55
import ChatRoom from '../xmpp/ChatRoom';
6+
import { handleStropheError } from '../xmpp/StropheErrorHandler';
67

78
import * as VideoSIPGWConstants from './VideoSIPGWConstants';
89

@@ -75,8 +76,12 @@ export default class JitsiVideoSIPGWSession extends Listenable {
7576
iq,
7677
() => {}, // eslint-disable-line @typescript-eslint/no-empty-function
7778
(error: any) => {
78-
logger.error(
79-
`Failed to ${action} video SIP GW session, error: `, error);
79+
handleStropheError(error, {
80+
operation: `${action} video SIP GW session`,
81+
roomJid: this.chatRoom.roomjid,
82+
sipAddress: this.sipAddress,
83+
userJid: this.chatRoom.connection.jid
84+
});
8085
this.setState(VideoSIPGWConstants.STATE_FAILED);
8186
},
8287
undefined);

modules/xmpp/ChatRoom.ts

Lines changed: 96 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import FileSharing from './FileSharing';
2222
import Lobby from './Lobby';
2323
import Polls from './Polls';
2424
import RoomMetadata from './RoomMetadata';
25+
import { handleStropheError } from './StropheErrorHandler';
2526
import XmppConnection, { ErrorCallback } from './XmppConnection';
2627
import XMPP, { FEATURE_TRANSCRIBER } from './xmpp';
2728

@@ -634,7 +635,11 @@ export default class ChatRoom extends Listenable {
634635
this.initialDiscoRoomInfoReceived = true;
635636
this.eventEmitter.emit(XMPPEvents.ROOM_DISCO_INFO_UPDATED);
636637
}, error => {
637-
logger.error('Error getting room info: ', error);
638+
handleStropheError(error, {
639+
operation: 'get room disco info',
640+
roomJid: this.roomjid,
641+
userJid: this.connection.jid
642+
});
638643
this.eventEmitter.emit(XMPPEvents.ROOM_DISCO_INFO_FAILED, error);
639644
},
640645
IQ_TIMEOUT);
@@ -694,10 +699,20 @@ export default class ChatRoom extends Listenable {
694699
formSubmit.c('field', { 'var': 'muc#roomconfig_whois' })
695700
.c('value').t('anyone').up().up();
696701

697-
this.connection.sendIQ(formSubmit);
702+
this.connection.sendIQ(formSubmit, undefined, error => {
703+
handleStropheError(error, {
704+
operation: 'submit room configuration form',
705+
roomJid: this.roomjid,
706+
userJid: this.connection.jid
707+
});
708+
});
698709

699710
}, error => {
700-
logger.error('Error getting room configuration form: ', error);
711+
handleStropheError(error, {
712+
operation: 'get room configuration form',
713+
roomJid: this.roomjid,
714+
userJid: this.connection.jid
715+
});
701716
});
702717
}
703718

@@ -1618,7 +1633,15 @@ export default class ChatRoom extends Listenable {
16181633
this.connection.sendIQ(
16191634
grantIQ,
16201635
result => logger.info('Set affiliation of participant with jid: ', jid, 'to', affiliation, result),
1621-
error => logger.error('Set affiliation of participant error: ', error));
1636+
error => {
1637+
handleStropheError(error, {
1638+
affiliation,
1639+
operation: 'set affiliation of participant',
1640+
participantJid: jid,
1641+
roomJid: this.roomjid,
1642+
userJid: this.connection.jid
1643+
});
1644+
});
16221645
}
16231646

16241647
/**
@@ -1637,7 +1660,15 @@ export default class ChatRoom extends Listenable {
16371660
this.connection.sendIQ(
16381661
kickIQ,
16391662
result => logger.info('Kick participant with jid: ', jid, result),
1640-
error => logger.error('Kick participant error: ', error), undefined);
1663+
error => {
1664+
handleStropheError(error, {
1665+
operation: 'kick participant',
1666+
participantJid: jid,
1667+
reason,
1668+
roomJid: this.roomjid,
1669+
userJid: this.connection.jid
1670+
});
1671+
}, undefined);
16411672
}
16421673

16431674
/* eslint-disable max-params */
@@ -1722,12 +1753,26 @@ export default class ChatRoom extends Listenable {
17221753
this.password = key;
17231754
onSuccess();
17241755
},
1725-
onError);
1756+
error => {
1757+
handleStropheError(error, {
1758+
operation: 'lock room (submit form)',
1759+
roomJid: this.roomjid,
1760+
userJid: this.connection.jid
1761+
});
1762+
onError(error);
1763+
});
17261764
} else {
17271765
onNotSupported();
17281766
}
17291767
},
1730-
onError);
1768+
error => {
1769+
handleStropheError(error, {
1770+
operation: 'lock room (get configuration)',
1771+
roomJid: this.roomjid,
1772+
userJid: this.connection.jid
1773+
});
1774+
onError(error);
1775+
});
17311776
}
17321777

17331778
/* eslint-enable max-params */
@@ -1759,7 +1804,13 @@ export default class ChatRoom extends Listenable {
17591804
}
17601805
});
17611806

1762-
sendIq && this.xmpp.connection.sendIQ(affiliationsIq.up());
1807+
sendIq && this.xmpp.connection.sendIQ(affiliationsIq.up(), undefined, error => {
1808+
handleStropheError(error, {
1809+
operation: 'set members affiliation',
1810+
roomJid: this.roomjid,
1811+
userJid: this.xmpp.connection.jid
1812+
});
1813+
});
17631814
}
17641815
// eslint-disable-next-line @typescript-eslint/no-empty-function
17651816
const errorCallback = onError ? onError : () => {};
@@ -1806,12 +1857,28 @@ export default class ChatRoom extends Listenable {
18061857
.up();
18071858
}
18081859

1809-
this.xmpp.connection.sendIQ(formToSubmit, onSuccess, errorCallback);
1860+
this.xmpp.connection.sendIQ(formToSubmit, onSuccess, error => {
1861+
handleStropheError(error, {
1862+
enabled,
1863+
operation: 'set members only (submit form)',
1864+
roomJid: this.roomjid,
1865+
userJid: this.xmpp.connection.jid
1866+
});
1867+
errorCallback(error);
1868+
});
18101869
} else {
18111870
errorCallback(new Error('Setting members only room not supported!'));
18121871
}
18131872
},
1814-
errorCallback);
1873+
error => {
1874+
handleStropheError(error, {
1875+
enabled,
1876+
operation: 'set members only (get configuration)',
1877+
roomJid: this.roomjid,
1878+
userJid: this.xmpp.connection.jid
1879+
});
1880+
errorCallback(error);
1881+
});
18151882
}
18161883

18171884

@@ -2105,7 +2172,16 @@ export default class ChatRoom extends Listenable {
21052172
this.connection.sendIQ(
21062173
iqToFocus,
21072174
result => logger.info('set mute', result),
2108-
error => logger.error('set mute error', error));
2175+
error => {
2176+
handleStropheError(error, {
2177+
mediaType,
2178+
mute,
2179+
operation: 'set mute participant',
2180+
participantJid: jid,
2181+
roomJid: this.roomjid,
2182+
userJid: this.connection.jid
2183+
});
2184+
});
21092185
}
21102186

21112187
/**
@@ -2305,7 +2381,15 @@ export default class ChatRoom extends Listenable {
23052381

23062382
resolve(this.cachedShortTermCredentials[service]);
23072383
},
2308-
reject);
2384+
error => {
2385+
handleStropheError(error, {
2386+
operation: 'get short term credentials',
2387+
roomJid: this.roomjid,
2388+
service,
2389+
userJid: this.connection.jid
2390+
});
2391+
reject(error);
2392+
});
23092393
});
23102394
}
23112395
}

modules/xmpp/JingleSessionPC.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { exists, findAll, findFirst, getAttribute, getText } from '../util/XMLUt
2727
import JingleSession from './JingleSession';
2828
import { JingleSessionState } from './JingleSessionState';
2929
import { MediaSessionEvents } from './MediaSessionEvents';
30+
import { handleStropheError } from './StropheErrorHandler';
3031
import XmppConnection from './XmppConnection';
3132

3233
const logger = getLogger('xmpp:JingleSessionPC');
@@ -1018,7 +1019,15 @@ export default class JingleSessionPC extends JingleSession {
10181019
logger.info(`${this} Got RESULT for "session-initiate"`);
10191020
},
10201021
error => {
1021-
logger.error(`${this} "session-initiate" error`, error);
1022+
handleStropheError(error, {
1023+
isP2P: this.isP2P,
1024+
operation: 'session-initiate',
1025+
remoteJid: this.remoteJid,
1026+
roomJid: this.room?.roomjid,
1027+
session: this.toString(),
1028+
sid: this.sid,
1029+
userJid: this.connection.jid
1030+
});
10221031
},
10231032
IQ_TIMEOUT);
10241033
}
@@ -1041,6 +1050,18 @@ export default class JingleSessionPC extends JingleSession {
10411050
private newJingleErrorHandler(failureCb?: (error: IJingleError) => void): ErrorCallback {
10421051
return errResponse => {
10431052

1053+
// Call handleStropheError for centralized error logging and analytics
1054+
handleStropheError(errResponse, {
1055+
isP2P: this.isP2P,
1056+
operation: 'Jingle IQ',
1057+
remoteJid: this.remoteJid,
1058+
roomJid: this.room?.roomjid,
1059+
session: this.toString(),
1060+
sid: this.sid,
1061+
state: this.state,
1062+
userJid: this.connection.jid
1063+
});
1064+
10441065
const error: IJingleError = {
10451066
code: undefined,
10461067
msg: undefined,

modules/xmpp/Lobby.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { $msg, Strophe } from 'strophe.js';
33

44
import { XMPPEvents } from '../../service/xmpp/XMPPEvents';
55

6+
import { handleStropheError } from './StropheErrorHandler';
7+
68
const logger = getLogger('xmpp:Lobby');
79

810
/**
@@ -455,7 +457,12 @@ export default class Lobby {
455457
this.xmpp.connection.sendIQ(msgToSend,
456458
() => { }, // eslint-disable-line no-empty-function
457459
e => {
458-
logger.error(`Error sending invite for ${membersToApprove}`, e);
460+
handleStropheError(e, {
461+
membersToApprove,
462+
operation: 'lobby approve members',
463+
roomJid: this.lobbyRoom,
464+
userJid: this.xmpp.connection.jid
465+
});
459466
});
460467
}
461468
}

0 commit comments

Comments
 (0)