Asterisk 16 PJSIP: Loss of SIP Header Values in Inter-Trunk Transfer

Hello, I’m new to Asterisk. I’m facing a problem and I’ve been struggling with it for a few days.

I have two asterisk servers. Let’s assume their names are ast182 and ast 189. I add the incoming information on the ast189 machine to the sipheader with same => n,Set(PJSIP_HEADER(add,${VAR_NAME})=${VAR_VALUE}) and send it to the transfer context to the ast182 machine. Here I direct the incoming call to the field trunk. This is how I do it.

On ast182

[transfer]
exten => _X.,1,NoOp(Transfer Request Incoming for Exten:  ${EXTEN})
same => n,Dial(PJSIP/${EXTEN}@saha)
same => n,Hangup()

When I open pjsip logger with this
asterisk -rx "pjsip set logger on"
the values ​​I set in the header come from ast189.
Example log:

<— Received SIP request (1248 bytes) from UDP:IPast189:5062 —>
INVITE sip:48196@IPast182:5062 SIP/2.0
Via: SIP/2.0/UDP IPast189:5062;rport;branch=z9hG4bKPj45739d6f-16bd-472d-8321-f1aebe6fe5a5
From: sip:1476329@IPast189;tag=10dfd5a3-962c-472d-92bd-7bdb2d447cda
To: sip:48196@IPast182
Contact: sip:asterisk@IPast189:5062
Call-ID: 6f09bed2-4220-4255-aec7-ddb53487d03c
CSeq: 23812 INVITE
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub, histinfo
Session-Expires: 1800
Min-SE: 90
cti_VdnLabel: TREDAS_OPERATOR
cti_CallDirection: 1
cti_ContractNumber: 0021164311
cti_IvrCallEndTime: 2024-02-13 22:41:46.015
cti_IvrCallStartTime: 2024-02-13 22:41:06.298
cti_CallAni: 1476329
cti_CallId: s200iap01-1707853265.521941
cti_TransferVDN: 48196
cti_CallStartTime: 2024-02-13 22:41:03.298
cti_IvrButton: 5
Max-Forwards: 70
User-Agent: Asterisk PBX 16.28.0
Content-Type: application/sdp
Content-Length: 239

However, it does not send any parameters when sending to the saha trunk.

<— Transmitting SIP request (939 bytes) to TCP:IPsaha:5060 —>
INVITE sip:48196@IPsaha:5060 SIP/2.0
Via: SIP/2.0/TCP IPast182:5060;rport;branch=z9hG4bKPja0ddd4b6-3f04-440a-baf7-1947dfcdf1c9;alias
From: sip:1476329@IPast182;tag=f7b5939b-b81d-4077-8442-7d1c8f3c1c01
To: sip:48196@IPsaha
Contact: sip:asterisk@IPast182:5060;transport=TCP
Call-ID: b50e7040-24fe-4833-8b08-f28f2499a6eb
CSeq: 29468 INVITE
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub, histinfo
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 16.28.0
Content-Type: application/sdp
Content-Length: 241

v=0
o=- 1507201859 1507201859 IN IP4 IPast182
s=Asterisk
c=IN IP4 IPast182
t=0 0
m=audio 16172 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

pjsip.conf

[saha]
type=endpoint
transport=transport-tcp
context=saha_inbound
disallow=all
allow=alaw

aors=saha_aors

[saha_aors]
type=aor
contact=sip:IPsaha:5060

The call is transferred, but the values ​​added to the header are not transferred.
I appreciate any help. Thanks!

Asterisk doesn’t forward SIP headers automatically. It’s up to you to write dialplan logic using the PJSIP_HEADER dialplan function.

Thank you @jcolp

I used like this and it works

[handler]
exten => addheader,1,Set(PJSIP_HEADER(add,X-MyHeader)=myvalue)
exten => addheader,2,Set(PJSIP_HEADER(add,X-MyHeader2)=myvalue2)

[somecontext]
exten => 1,1,Dial(PJSIP/${EXTEN},,b(handler^addheader^1))

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