Is it possible to send variables from freeswitch to sipjs

483 views
Skip to first unread message

Sports highfive

unread,
Jul 29, 2021, 5:16:57 AM7/29/21
to SIP.js
Hi

I know its possible to send data from sipjs to freeswitch using X-headers, but is there any way to do the opposite? I need to retreive freeswitch uuid variable on client end. Please guide me, any help is highly appreciated.

Thanks
Waqar

jolo milosz

unread,
Aug 2, 2021, 7:17:19 AM8/2/21
to SIP.js
Hi Waqar, 

I'm in very same place as you are. Starting to review possibilities (newest SIP client i.e. .0.20.0).
What I noticed so far is that we can use data object within Session, however it's described as object for Client inner usage so it might not be very suitable for you.

Second option, which currently I'll try to implement, is usage of SessionInfoOptions - still not sure if it's a good choice though.

Hope this will help you, let me know if you'll come up with anything - I can promise I'll do the same.

If anyone else could relate on this topic, PLEASE DO.

Slavik Bialik

unread,
Aug 2, 2021, 8:24:50 AM8/2/21
to SIP.js
Hi,
for some reason my replies here went directly to Muhammad, so I helped him with that and I will share with you what I said to him.

What you can do on FreeSWITCH side is to configure in the dialplan extension a response header, like that for example:
sip_rh_X-UUID=${uuid}

Pay attention that I added the 'r' letter before 'h', because 'rh' means response header.
A response header will be attached on the 200OK in case of outgoing call from your SIP.js, so when someone is answering the call on the other end, you'll get a 200OK with that custom SIP header.

And with SIP.js you can actually very easily catch the response (200OK) and take whatever you need from, so in function where you implement an outgoing call just do something like that:

var inviterInviteOptions: InviterInviteOptions = {
    requestDelegate: {
    // Catch 2XX SIP messages (mostly the 200 OK) to detect the call answer event.
    onAccept(response: AckableIncomingResponseWithSession)
    {
       ....
       ....
       var callUUID = response.message.getHeader("X-UUID") || "";
       ....
       ....
    }
   }
}

So on SIP.js client you just need to catch it by setting InviterInviteOptions object with onAccept callback and pass this object to the "invite" function.

Hope it helps.

jolo milosz

unread,
Aug 2, 2021, 8:39:03 AM8/2/21
to SIP.js

Hi,

thanks a lot for that info!
Reply all
Reply to author
Forward
0 new messages