How to get PJSIP header of Local Channel

Asterisk certified/16.8-cert11

I need to PJSIP HEADER in Local Channel.

My dialplan

exten => _X., NoCDR
same => n, Answer()
same => n, Set(_outgoing=xyz)
same => n, Dial(local/${EXTEN}@def,,t)

exten => _X.,1,Set(CDR(typ)=out)
same => n, Dial(PJSIP/${EXTEN}@${outgoing})

exten => h,1, Set(somevar=${PJSIP_HEADER(read,X-VND-INIT-RATE)})

I can’t do it in the [abc] context because that header supplies my provier. I only connect to the provider in the [def] context.
In the above dialplan I get the error:

res_pjsip_header_funcs.c:454 func_read_header: This function requires a PJSIP channel.

Is it possible to extract the PJSIP header from the local channel? This dialplan MUST look like this and it is not possible to change it.

No, PJSIP_HEADER only operates on a PJSIP channel. It will not work on a Local channel.

How to get this header?

What do you really want to do? A local channel obviously doesn’t have PJSIP headers!

Also, I don’t think that PJSIP_HEADER works, on responses. If it did, you would need to run it on the outgoing channel, which I think you can do with the e option on Dial.

I think this is all about accessing B side information. I don’t think it is relevant whether or not hte A side is a local channel.

Also note that you should not be using a certified version unless you have a support contract with Sangoma, and if you do, you should not be asking here.

When making a call, I receive information from the provider in the header about the amount of the connection fee. I would like to save it to a variable.

So, in spite of your example having a CANCEL (for which normal providers would not charge), it’s normally on the BYE or the response to the BYE. I’m sure accessing headers from those is not supported.

There is no support for getting headers from a 180 Ringing, 183 Session Progress, or a BYE. Only from an incoming INVITE and the 200 OK to our outgoing INVITE[1].

[1] [ASTERISK-29999] pjsip: Get information from 200 OK INVITE reply headers - Digium/Asterisk JIRA