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.
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.