[OpenSIPS-Users] Media server communication with OpenSIPS

Gregory Massel greg at switchtel.co.za
Thu Dec 29 19:28:40 UTC 2022

You can send custom headers from Asterisk to OpenSIPS using:


If you need Asterisk to receive customer headers from OpenSIPS, you can 
read custom headers added by OpenSIPS to its 200 response using:


If you are already midway through a call, you can force an UPDATE or 
re-INVITE using:


While I haven't personally tested, I'd expect that you should be able to 
signal custom information midway through a call with a 
Set(PJSIP_HEADER(add,X-MyHeader)=myvalue) followed by a 
Set(PJSIP_SEND_SESSION_REFRESH()=invite). This should then trigger a 
re-INVITE carrying the new X-MyHeader within it.

Similarly, after triggering the a re-INVITE or UPDATE, you should then 
be able to do a Set(MYVAR=PJSIP_RESPONSE_HEADER(read,X-MyHeader)) to 
extract what OpenSIPS has sent back to Asterisk in its 200 response.

Although more messy, there are also other tricks that you can use, 
including the CONNECTEDLINE function:



e.g. If you did a 
Set(CONNECTEDLINE(name)=Information_I_wish_to_share_with_OpenSIPS), then 
this will, in one step, trigger an UPDATE or re-INVITE carrying the new 
connected party name in the SIP headers, detail which you can then 
extract from OpenSIPS. Similarly, you can also use this approach read 
information that OpenSIPS has sent to Asterisk, with a 

I mention this in case, for whatever reason, the first approach 
(described above) doesn't work as planned, however, the first approach 
is definitely preferable as you can carry the information in your own X- 
header, making it far easier to send/receive multiple headers.

> On Tue, Dec 27, 2022 at 8:55 AM Wadii ELMAJDI | Evenmedia 
> <wadii at evenmedia.fr> wrote:
> >
> > Hello,
> >
> >
> > I am using Asterisk as a media server behind OpenSIPS.
> > I need to send some additional data to opensips during the call or 
> at the latest during the hangup. For instance a custom hang up reason.
> > Asterisk does not allow neither to send a sequential request withing 
> an ongoing dialog, nor add headers to a BYE method.
> > The current solution I’m using is pushing a dialog var 
> (dlg_push_var) using Call-ID via (mi_http), but that means I rely on a 
> curl http request during my call…
> > Is there any better option for a direct communication between the 
> two boxes during a call ? without any intermediate server (Redis DB …)
> >
> > Thank you
> >
> > _______________________________________________
> > Users mailing list
> > Users at lists.opensips.org
> > http://lists.opensips.org/cgi-bin/mailman/listinfo/users
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20221229/27d58971/attachment.html>

More information about the Users mailing list