jitsi / lib-jitsi-meet

A low-level JS video API that allows adding a completely custom video experience to web apps.
Apache License 2.0
1.34k stars 1.11k forks source link

Error handling - Focus, Strophie, Jingle error #1365

Open bhuvaneshdesai opened 4 years ago

bhuvaneshdesai commented 4 years ago

I have setup video calling for most part it works fine but every once in a while following errors are thrown i tried all sort of event handlers to catch these errors but didn't help.

(i would try to avoid the JitsiMeetJS.getGlobalOnErrorHandler()).

Best Would be if anyone explain why those errors caused and what's ideal way to handle them or even better prevent them in first place.

  1. Focus error, retry after x

    Error: Focus error, retry after 1000
    at l._allocateConferenceFocusError(/js/lib-jitsi-meet.min.js:10:169107)
    at ? (/js/lib-jitsi-meet.min.js:10:168158)
    at I.Handler.handler(/js/lib-jitsi-meet.min.js:1:31297)
    at I.Handler.run(/js/lib-jitsi-meet.min.js:1:26596)
    at ? (/js/lib-jitsi-meet.min.js:1:35034)
    at Object.forEachChild(/js/lib-jitsi-meet.min.js:1:18258)
    at I.Connection._dataRecv(/js/lib-jitsi-meet.min.js:1:34883)
    at P.Bosh._onRequestStateChange(/js/lib-jitsi-meet.min.js:1:54868)
    at XMLHttpRequest.r(../../src/helpers.ts:90:17)
  2. Strophe: request id x error y happened

    Error: Strophe: request id 114.1 error 0 happened
    at Object.r.Strophe.log(/js/lib-jitsi-meet.min.js:17:17881)
    at Object.error(/js/lib-jitsi-meet.min.js:1:23478)
    at P.Bosh._onRequestStateChange(/js/lib-jitsi-meet.min.js:1:54925)
    at XMLHttpRequest.r(../../src/helpers.ts:90:17)
  3. Jingle error

    Error: Jingle error: {"reason":"timeout","session":"JingleSessionPC[p2p=true,initiator=false,sid=c3598f3a49b2]"}
    at ? (/js/lib-jitsi-meet.min.js:1:220487)
    at I.TimedHandler.handler(/js/lib-jitsi-meet.min.js:1:31407)
    at I.TimedHandler.run(/js/lib-jitsi-meet.min.js:1:26948)
    at I.Connection._onIdle(/js/lib-jitsi-meet.min.js:1:42980)
    at ? (/js/lib-jitsi-meet.min.js:1:43150)
    at r(../../src/helpers.ts:90:17)
  4. Received P2P "session-initiate" when should not be in P2P mode

    Error: Received P2P "session-initiate" when should not be in P2P mode
    at ie._rejectIncomingCall(/js/lib-jitsi-meet.min.js:10:60084)
    at ie._onIncomingCallP2P(/js/lib-jitsi-meet.min.js:10:57951)
    at ie.onIncomingCall(/js/lib-jitsi-meet.min.js:10:58070)
    at a.emit(/js/lib-jitsi-meet.min.js:1:129707)
    at g.onJingle(/js/lib-jitsi-meet.min.js:10:200299)
    at I.Handler.run(/js/lib-jitsi-meet.min.js:1:26596)
    at ? (/js/lib-jitsi-meet.min.js:1:35034)
    at Object.forEachChild(/js/lib-jitsi-meet.min.js:1:18258)
    at I.Connection._dataRecv(/js/lib-jitsi-meet.min.js:1:34883)
    at P.Bosh._onRequestStateChange(/js/lib-jitsi-meet.min.js:1:54868)
    at XMLHttpRequest.r(../../src/helpers.ts:90:17)

I get following errors too but above ones are important

Error: Strophe: error: Cannot read property 'addListener' of null
  at Object.r.Strophe.log(/js/lib-jitsi-meet.min.js:17:17881)
  at Object.fatal(/js/lib-jitsi-meet.min.js:1:23529)
  at Object._handleError(/js/lib-jitsi-meet.min.js:1:23139)
  at I.Handler.run(/js/lib-jitsi-meet.min.js:1:26624)
  at ? (/js/lib-jitsi-meet.min.js:1:35034)
  at Object.forEachChild(/js/lib-jitsi-meet.min.js:1:18258)
  at I.Connection._dataRecv(/js/lib-jitsi-meet.min.js:1:34883)
  at P.Bosh._onRequestStateChange(/js/lib-jitsi-meet.min.js:1:54868)
  at XMLHttpRequest.r(../../src/helpers.ts:90:17)
Error: Strophe: TypeError: Cannot read property 'addListener' of null
    at s._onMediaSessionStarted (https://beta.pyjamahr.com/js/lib-jitsi-meet.min.js:17:128221)
    at a.<anonymous> (https://beta.pyjamahr.com/js/lib-jitsi-meet.min.js:17:128074)
    at a...
  at s._onMediaSessionStarted(/js/lib-jitsi-meet.min.js:17:128221)
  at a.<anonymous>(/js/lib-jitsi-meet.min.js:17:128074)
  at a.emit(/js/lib-jitsi-meet.min.js:1:129707)
  at ? (/js/lib-jitsi-meet.min.js:10:67184)
  at I.Handler.handler(/js/lib-jitsi-meet.min.js:1:31189)
  at I.Handler.run(/js/lib-jitsi-meet.min.js:1:26596)
  at ? (/js/lib-jitsi-meet.min.js:1:35034)
  at Object.forEachChild(/js/lib-jitsi-meet.min.js:1:18258)
  at I.Connection._dataRecv(/js/lib-jitsi-meet.min.js:1:34883)
  at P.Bosh._onRequestStateChange(/js/lib-jitsi-meet.min.js:1:54868)
  at XMLHttpRequest.r(../../src/helpers.ts:90:17)
  at Object.r.Strophe.log(/js/lib-jitsi-meet.min.js:17:17881)
  at Object.fatal(/js/lib-jitsi-meet.min.js:1:23529)
  at Object._handleError(/js/lib-jitsi-meet.min.js:1:22920)
  at I.Handler.run(/js/lib-jitsi-meet.min.js:1:26624)
  at ? (/js/lib-jitsi-meet.min.js:1:35034)
  at Object.forEachChild(/js/lib-jitsi-meet.min.js:1:18258)
  at I.Connection._dataRecv(/js/lib-jitsi-meet.min.js:1:34883)
  at P.Bosh._onRequestStateChange(/js/lib-jitsi-meet.min.js:1:54868)
  at XMLHttpRequest.r(../../src/helpers.ts:90:17)
bhuvaneshdesai commented 4 years ago
  1. The focus error will probably get resolved by trying this method https://github.com/jitsi/jitsi-meet/issues/3543
  2. Strophe: request id x error y happened -> one of the reason this is causing is if internet is disconnected or lost to tackle that i have added following code (which is not working to catch exceptions)
    
        window.addEventListener('offline', disconnect);

async function disconnect() { try { if (jitsiAPI.room) { Object.entries(connectionListners).forEach(([event, fn]) => { jitsiAPI.room.off(JitsiMeetJS.events.conference[event], fn); }); Object.keys(jitsiAPI.room.participants).forEach((id) => { jitsiAPI.room.kickParticipant(id); }); await jitsiAPI.room.leave(); jitsiAPI.disconnect(); } } catch (error) { jitsiAPI.disconnect(); console.log('error leaving room', error); } }

_note in above snippet `connectionListners` is just object having event name as key and function which should be trigged when that event occurred_

other errors i was not able to find any particular reason yet.

Also to catch errors from global handler i used same snippet from jitsi-meet
that is
```javascript
function _setErrorHandlers() {
    // attaches global error handler, if there is already one, respect it
    if (JitsiMeetJS.getGlobalOnErrorHandler) {
        const oldOnErrorHandler = window.onerror;

        // eslint-disable-next-line max-params
        window.onerror = (message, source, lineno, colno, error) => {
            JitsiMeetJS.getGlobalOnErrorHandler(
                message, source, lineno, colno, error);

            if (oldOnErrorHandler) {
                oldOnErrorHandler(message, source, lineno, colno, error);
            }
        };

        const oldOnUnhandledRejection = window.onunhandledrejection;

        window.onunhandledrejection = function(event) {
            JitsiMeetJS.getGlobalOnErrorHandler(
                null, null, null, null, event.reason);

            if (oldOnUnhandledRejection) {
                oldOnUnhandledRejection(event);
            }
        };
    }
}

I was able to catch the error. but its still got logged in console which the sentry reported

DanielMcAssey commented 3 years ago

Is there no answer to this?