onsip / SIP.js

A simple, intuitive, and powerful JavaScript signaling library
https://sipjs.com
MIT License
1.84k stars 693 forks source link

Issue with onBye event not triggering in outgoing calls #1047

Closed EndikaRamos closed 1 year ago

EndikaRamos commented 1 year ago

Hello,

I am experiencing an issue related to the onBye event not being triggered in outgoing calls. I have implemented the following code snippet to capture the "bye" event:

sipUserAgent.delegate = {
    onConnect: () => {
        // This works fine
    },
    onDisconnect: (error) => {
        // This works fine
    },
    onInvite: (invitation) => {
        // This works fine
    },
    onBye: (bye) => {
        // I am not receiving the event here
        console.log('I am here');
    },
};

In the Chrome console, I can see that the "Session.onByeRequest" is being called when a BYE request is received:

Mon Jun 12 2023 11:16:36 GMT+0200 (Central European Summer Time) | sip.invite-dialog | INVITE dialog 62amv9ht4ag6vmkceudivb7oasg08kas26413ee9 received BYE request
Mon Jun 12 2023 11:16:36 GMT+0200 (Central European Summer Time) | sip.Inviter | Session.onByeRequest
Mon Jun 12 2023 11:16:36 GMT+0200 (Central European Summer Time) | sip.Inviter | Session 62amv9ht4ag6vmkceudivb7oasg08k transitioned to state Terminated

However, the console.log statement inside the onBye function is not being executed.

Could you please assist me in resolving this issue? Any insights or suggestions would be greatly appreciated.

Thank you for your attention to this matter.

Best regards, Endika

EndikaRamos commented 1 year ago

Hello again, I have identified the correct solution, and it involves delegating the event handling to the SIP.Inviter object.

sipInviter.delegate = {
    onBye: (session) => {
        console.log('I am here');
    },
};

I apologize for any inconvenience

Endika