InnovateAsterisk / Browser-Phone

A fully featured browser based WebRTC SIP phone for Asterisk
https://www.innovateasterisk.com
GNU Affero General Public License v3.0
489 stars 240 forks source link

Possible causes of Null Session sometimes. #108

Open pravin-navle opened 3 years ago

pravin-navle commented 3 years ago

Hi Conrad, The browser phone is working great so far. Today I saw Audio Answer failed, null session message in the console for the first time. I'm sharing the log :

Wed Oct 28 2020 10:39:58 GMT+0530 (India Standard Time) | sip.sipmessage | header "Content-Disposition" not present Wed Oct 28 2020 10:39:58 GMT+0530 (India Standard Time) | sip.dialog | new UAS dialog created with status EARLY New Incoming Call! "1234567" <1234567> CurrentCalls - undefined CurrentCalls - 0 Selecting Buddy: 1603861798314F9A Auto Answer Call... Auto Answer audio Calling ... Audio ... Audio Is Playing Done ... Audio Answer failed, null session AnswerAudioCall @ phoneV6.js:2722 web_hook_on_invite s web_hook_on_invite @ phone.html:91 Audio Is Playing ... Registered! web_hook_on_register r

Today I got a message Audio Answer failed, null session from the AnswerAudioCalls function. I need your help to understand in which case the getSession() function can return the session as null.

Thank you

InnovateAsterisk commented 3 years ago

This could happen if:

    var session = getSession(buddy);

returns null, and it would rerun null if this code does not find the session

    var rtnSession = null;
    $.each(userAgent.sessions, function (i, session) {
        if(session.data.buddyId == buddy) {
            rtnSession = session;
            return false;
        }
    });
    return rtnSession;

It is possible that the session is removed from the array in userAgent.sessions array, before this code executes. It may have been an unusual race condition. If you can try trace the sequence of events it may help.