How to get customer header in PJSIP using sip.js

Not able to get Header values. Please let me know if i am missing some thing

[from-internal]
exten => _1XX,1,NoOp(Starting call to ${EXTEN})
same => n,Set(mute_status=${PJSIP_HEADER(read,X-Call-Mute)})
same => n,NoOp(Mute Status: ${mute_status})
same => n,Set(CDR(Mute)=${mute_status})
same => n,Dial(PJSIP/${EXTEN},60)
same => n,Hangup()

Js code is

const extraHeaders = [X-Call-Mute: yes, X-Caller-ID: ${'202'}] ;
this.currentSession.invite({
extraHeaders: extraHeaders
}).then(() => {
console.log(this.currentSession);
console.log(‘Mute status sent to Asterisk’);
}).catch(error => {
console.error(‘Error sending mute status to Asterisk:’, error);
});

You haven’t provided a SIP trace to confirm that the header is present, or a console log from Asterisk. As well if this is a re-INVITE, then you can’t get headers from re-INVITEs.

There is no such header in that INVITE.

I am new to asterisk Can you please show me how invite look like with custom headers i will be thank full.

My task is to create a log of mute in CDR

That has nothing to do with Asterisk. This is at SIP and JsSIP level. I can’t comment on JsSIP, but for SIP it’s an additional header in the format of “Name: Value”.

As I mentioned before too, if you’re sending multiple of these during a call in the form of re-INVTIEs then you will not be able to get the header from them.

As for getting your custom headers through with JsSip, try

const extraHeaders = [ “X-Call-Mute: yes”, “X-Caller-ID: 202” ];

It takes a list of headers, each item is the full header (name and value.)

  • Darrin

On Wed, Sep 4, 2024 at 6:45 AM jcolp via Asterisk Community <notifications@asterisk.discoursemail.com> wrote:

jcolp Asterisk Project Lead
September 4

That has nothing to do with Asterisk. This is at SIP and JsSIP level. I can’t comment on JsSIP, but for SIP it’s an additional header in the format of “Name: Value”.

As I mentioned before too, if you’re sending multiple of these during a call in the form of re-INVTIEs then you will not be able to get the header from them.


Visit Topic or reply to this email to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, click here.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.