How to fetch SIP_HEADER(Reason) in failed calls n Asterisk 16 using Sip trunk

exten => h,1,NoOp(>>>>>>>)
exten => h,n,NoOp(>SIPHeader>>>>${SIP_HEADER(Reason)}>>>>)

This is working for Success Calls but not working for Failed calls. Kindly help as I need to map actual error codes send from Sip trunk provider.I am getting below SIP messages with error code in logs

<— SIP read from UDP: —>
SIP/2.0 480 Temporarily Unavailable

Firstly you should be using at least Asterisk 18. Secondly, there is no such thing as a SIP trunk as far as Asterisk is concerned. The same logic would apply to any SIP peer.

The channel private structure for the outgoing leg no longer exists at the point where you are calling SIP_HEADER, and you are probably also calling it on the wrong channel. However I believe the numeric part of the data is captured, and can be accessed using the HANGUPCAUSE function.

Hello David
I am able to receive these headers in Success calls. Numeric part was also captured in HANUPCAUSE but only in success calls.
How i can fetch these headers and how i can fetch channel details in failed calls.

Does the hangup causes[1] support really not work? It’s supposed to give you the list of channels, and the cause (including SIP response code).

Otherwise there is no ability to access any headers on the SIP response. (What you’ve posted is not actually a header, it’s the SIP first line)

[1] Hangup Cause - Asterisk Project - Asterisk Project Wiki

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