I have an asterisk 15.5 with PJSIP configured with two endpoints: 1 sip trunk and 1 sip extension. When placing a call from extension through that trunk, and destination number is not in service, from the trunk I receive a 404 but PJSIP reply to my extension with a 503, that is not precise as much as I need.
00017 1544111045 * <== #.#.5.12:5060 SIP/2.0 404 Not Found
00018 1544111045 * ==> #.#.5.12:5060 ACK sip:092532145@#.#.5.12:5060 SIP/2.0
00019 1544111045 * ==> 192.168.1.243:65104 SIP/2.0 503 Service Unavailable
Is there any documented/undocumented settings I can configure to refer to the extension the exact failure code?
There is no configuration, but the Hangup application accepts a cause code[1] and there are methods to query the cause codes of the outgoing side. As for why it didn’t forward the 404, it’s because to the calling party the extension was found in Asterisk.
[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Application_Hangup
There are dialplan functions[2] to inspect and the wiki contains a mapping[3].
[2] https://wiki.asterisk.org/wiki/display/AST/Hangup+Cause [3] https://wiki.asterisk.org/wiki/display/AST/Hangup+Cause+Mappings
Solution was found by JColp on Asterisk's Community: Thanks man.
https://community.asterisk.org/t/pjsip-not-passing-correct-sip-code-to-endpoint/77510