How Do I Retrieve The Call-ID From The SIP INVITE When Using Originate On PJSIP?

Home » Asterisk Users » How Do I Retrieve The Call-ID From The SIP INVITE When Using Originate On PJSIP?
Asterisk Users 1 Comment

Using chan_sip, we are able to retrieve the Call-ID using the SIPCALLID channel variable. This works for both inbound and outbound (Originated) calls.

For PJSIP this variable doesn’t get set. Instead, for inbound calls we retrieve the Call-ID from the INVITE packet using the PJSIP_HEADER(read,Call-ID,1). However, this doesn’t work for outbound calls because the datastore hasn’t been set.

[08/23 07:14:41.185] DEBUG[59544] res_pjsip_header_funcs.c: There was no datastore from which to read headers.
[08/23 07:14:41.185] DEBUG[59556][C-00000007] pbx_variables.c: Function PJSIP_HEADER(read,Call-ID,1) result is ‘(null)’

Not being able to access the datastore for Originated PJSIP calls even though there is already an event: newchannel seem like something was missed with the PJSIP outbound calls.

Any suggestions?

Have a great day!

Dan

One thought on - How Do I Retrieve The Call-ID From The SIP INVITE When Using Originate On PJSIP?

  • Please Disregard. I found the solution.

    In case anyone else runs into this, use (CHANNEL(pjsip,call-id)) and not the PJSIP_HEADER(read, …)

    From: asterisk-users On Behalf Of Dan Cropp Sent: Thursday, August 23, 2018 9:32 AM
    To: asterisk-users@lists.digium.com Subject: [asterisk-users] How do I retrieve the Call-ID from the SIP INVITE when using Originate on PJSIP?

    Using chan_sip, we are able to retrieve the Call-ID using the SIPCALLID channel variable. This works for both inbound and outbound (Originated) calls.

    For PJSIP this variable doesn’t get set. Instead, for inbound calls we retrieve the Call-ID from the INVITE packet using the PJSIP_HEADER(read,Call-ID,1). However, this doesn’t work for outbound calls because the datastore hasn’t been set.

    [08/23 07:14:41.185] DEBUG[59544] res_pjsip_header_funcs.c: There was no datastore from which to read headers.
    [08/23 07:14:41.185] DEBUG[59556][C-00000007] pbx_variables.c: Function PJSIP_HEADER(read,Call-ID,1) result is ‘(null)’

    Not being able to access the datastore for Originated PJSIP calls even though there is already an event: newchannel seem like something was missed with the PJSIP outbound calls.

    Any suggestions?

    Have a great day!

    Dan