Using "onAck" with SessionDelegate

166 views
Skip to first unread message

Slavik Bialik

unread,
Feb 1, 2021, 5:44:56 AM2/1/21
to SIP.js
Hi,
I am trying to understand how to use the "onAck" method of the SessionDelegate.
Here is the documentation:

This is what I am trying to do with my code:

        const incomingSession: Session = this.invitation;
        incomingSession.delegate = {
            // no `onAck` available here...
        };

But can't get the "onAck" method to show when I am using auto complete in the brackets of the "delegate". 

What is the proper way to implement this?
Thanks!

Eric Green

unread,
Feb 1, 2021, 6:25:55 AM2/1/21
to SIP.js
You are looking at the core documentation. But an invitation is actually in the api layer and returns a session-delegate. The api layer session-delegate does not have an OnAck method. See the links below.

Slavik Bialik

unread,
Feb 1, 2021, 6:30:16 AM2/1/21
to SIP.js
OK, I understand.
So there's no way to catch the ACK on incoming INVITE?
My issue is that I am having sometimes a race condition in my deployment. That's why I want to rely only on ACKs.
Today I am relying on "SessoinState.Established" in order to know if the call has been answered or not. But today I found out that it may cause some race conditions in my system.

Thanks! Hope there's another solution for my issue.

Eric Green

unread,
Feb 1, 2021, 8:03:51 AM2/1/21
to SIP.js
Not sure what your race condition is. SessionState.Established should be what you are looking for.

Slavik Bialik

unread,
Feb 1, 2021, 8:13:17 AM2/1/21
to SIP.js
We are running some CI tests, and those tests are being done one by one very quickly without making some delays between all of them.
So what happened is that we are answering a call and quickly hanging it up (only after SessionState becomes ESTABLISHED). This is part of the test being done on CI.
But then on FreeSWITCH side, the hang up is received so fast, that it still didn't bridge between both call legs and didn't consider the call as "answered" yet.
Combining the above with using a call center on module, instead of hanging the call, FreeSWITCH detects that the call got disconnected before a complete bridge, so FreeSWITCH is returning the caller to the queue instead of disconnecting the call.
And it is all matter of ~40 msec between the ACK and the BYE. 
So if I could detect when ACK is being returned, and only then send the hang up command it would solve this race condition.

I would suggest it as an enhancement to be able to listen on the ACK messages (onAck) using SIP.js API, as I think it is a better way to really know if the call got really answered.

Slavik Bialik

unread,
Feb 11, 2021, 8:54:30 AM2/11/21
to SIP.js
Hi Eric,
After changing some of the source code, I am now able to serve the "onAck" to SessionDelegate.
But for now it works only for inbound calls, where the ACK is being received from PBX side (And not sent out from SIP.js client)
I really want to make a pull request on this feature, would it interest you?
Thanks!

Reply all
Reply to author
Forward
0 new messages