Changing SIP cause codes

Hi All,

On my call flow, I am seeing a random "SIP 500 Server Internal Error " from the SIP Provider with a ISDN cause code text of “Network out of order”. But, is working on the same destination again in few minutes. I guess, it is the destination partner network issue, am i correct?

So, for these SIP 500s received by the provide, i want a SIP 480 returned from my asterisk to my client (caller) instead of them seeing the SIP 500 as received from the provider (forwarded to them by the Asterisk).

Can we in asterisk change the SIP return codes ? Say if SIP 500 is returned, i want a 503 or a 480 returned instead of the 500 to the caller. IS this doable?

To modify SIP response codes in Asterisk, you can use the SIP_HEADER function within the dialplan. Capture the SIP 500 error using ${SIP_HEADER(StatusCode)} and then change it to desired code using SIP_HEADER(Response) . Finally, continue the call flow as usual.

SIP_HEADER is read only and the special values quoted are undocumented.

You use Hangup() with an ISDN cause code that maps to the desired SIP value. Not all values are possible.

Recent versions of Asterisk with PJSIP also have the ability to hangup with an explicit SIP response code in the dialplan[1] instead of relying on lossy ISDN cause code conversion.

[1] PJSIPHangup - Asterisk Documentation

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