Need to unset Alert-Info for outbound route

I recently started working with a different sip trunk provider, Bandwidth. I have noticed that if Alert-Info is set on my inbound route, the sipheader is maintained through the followme into the outbound route. Bandwidth replies with 400 Bad Request, cause="[line 011] SIP syntax error". Line 11 of the sip invite is " Alert-Info: <127.0.0.1>;info=info=ring1".

After much google and forum searches, this is what I have tried thus far.
Inside /etc/asterisk/extensions_custom.conf I added
[macro-dialout-trunk-predial-hook]
exten => 1,1,Set(PJSIP_HEADER(remove,Alert-Info)=)
exten => s,1,SIPRemoveHeader(Alert-Info:)
exten => s,n,MacroExit()

Here is the section of log that I think is relevant during the test call.

[2019-07-17 14:03:21] VERBOSE[26262][C-00000753] app_stack.c: PJSIP/Bandwidth1-000010fd Internal Gosub(func-apply-sipheaders,s,1(3)) start
[2019-07-17 14:03:21] VERBOSE[26262][C-00000753] pbx.c: Executing [s@func-apply-sipheaders:1] NoOp(“PJSIP/Bandwidth1-000010fd”, “Applying SIP Headers to channel PJSIP/Bandwidth1-000010fd”) in new stack
[2019-07-17 14:03:21] VERBOSE[26262][C-00000753] pbx.c: Executing [s@func-apply-sipheaders:2] Set(“PJSIP/Bandwidth1-000010fd”, “TECH=PJSIP”) in new stack
[2019-07-17 14:03:21] VERBOSE[26262][C-00000753] pbx.c: Executing [s@func-apply-sipheaders:3] Set(“PJSIP/Bandwidth1-000010fd”, “SIPHEADERKEYS=Alert-Info”) in new stack
[2019-07-17 14:03:21] VERBOSE[26262][C-00000753] pbx.c: Executing [s@func-apply-sipheaders:4] While(“PJSIP/Bandwidth1-000010fd”, “1”) in new stack
[2019-07-17 14:03:21] VERBOSE[26262][C-00000753] pbx.c: Executing [s@func-apply-sipheaders:5] Set(“PJSIP/Bandwidth1-000010fd”, “sipheader=info=ring1”) in new stack
[2019-07-17 14:03:21] VERBOSE[26262][C-00000753] pbx.c: Executing [s@func-apply-sipheaders:6] ExecIf(“PJSIP/Bandwidth1-000010fd”, “0?SIPRemoveHeader(Alert-Info:)”) in new stack
[2019-07-17 14:03:21] VERBOSE[26262][C-00000753] pbx.c: Executing [s@func-apply-sipheaders:7] ExecIf(“PJSIP/Bandwidth1-000010fd”, “0?Set(PJSIP_HEADER(remove,Alert-Info)=)”) in new stack
[2019-07-17 14:03:21] VERBOSE[26262][C-00000753] pbx.c: Executing [s@func-apply-sipheaders:8] ExecIf(“PJSIP/Bandwidth1-000010fd”, “1?Set(sipheader=<127.0.0.1>;info=info=ring1)”) in new stack
[2019-07-17 14:03:21] VERBOSE[26262][C-00000753] pbx.c: Executing [s@func-apply-sipheaders:9] ExecIf(“PJSIP/Bandwidth1-000010fd”, “0?SIPAddHeader(Alert-Info:<127.0.0.1>;info=info=ring1)”) in new stack
[2019-07-17 14:03:21] VERBOSE[26262][C-00000753] pbx.c: Executing [s@func-apply-sipheaders:10] ExecIf(“PJSIP/Bandwidth1-000010fd”, “1?Set(PJSIP_HEADER(add,Alert-Info)=<127.0.0.1>;info=info=ring1)”) in new stack
[2019-07-17 14:03:21] VERBOSE[26262][C-00000753] pbx.c: Executing [s@func-apply-sipheaders:11] EndWhile(“PJSIP/Bandwidth1-000010fd”, “”) in new stack

The server is a Sangoma 7 install Freepbx14 and Asterisk 16.3 with latest updates.
All endpoints are pjsip and the Trunks are PJSIP

Try this:

[macro-dialout-trunk-predial-hook]
exten => s,1,NoOp(Entering user defined context [macro-dialout-trunk-predial-hook] in extensions_custom.conf)
exten => s,n,GoSub(func-set-sipheader,s,1(Alert-Info,unset))
exten => s,n,MacroExit()
1 Like

Lorne Gaetz, thank you for fixing this issue. After pasting in the code, all test calls have succeeded. The desk phone is getting the alert-info, so that is perfect. Then when the call is forwarding through followme, the alert info is being removed.

Thank you very much for your assistance.

2 Likes

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