<div dir="ltr">Hi,<div>rfc 3261 (the one and only) states at section16.7</div><div><br></div><div>"<br>         A proxy which receives a 503 (Service Unavailable) response<br>         SHOULD NOT forward it upstream unless it can determine that any<br>         subsequent requests it might proxy will also generate a 503.<br>         In other words, forwarding a 503 means that the proxy knows it<br>         cannot service any requests, not just the one for the Request-<br>         URI in the request which generated the 503.  If the only<br>         response that was received is a 503, the proxy SHOULD generate<br>         a 500 response and forward that upstream.<br>"<br></div><div><br></div><div>So Kamailio behavior is absolutely legitimate. If you want to change it you have to use the following tm parameter: <a href="http://www.kamailio.org/docs/modules/devel/modules/tm.html#remap_503_500" target="_blank">http://www.<wbr>kamailio.org/docs/modules/<wbr>devel/modules/tm.html#remap_<wbr>503_500</a>.</div><div><br></div><div>Best regards,</div><div><br></div><div>Federico</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 14, 2018 at 6:29 PM, Sergiu Pojoga <span dir="ltr"><<a href="mailto:pojogas@gmail.com" target="_blank">pojogas@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Alex,<div><br></div><div><div># ----- tm params -----</div><div>modparam("tm", "failure_reply_mode", 3)<br></div></div><div><br></div><div>I use drouting, here's the main logic.</div><div><br></div><div>request_route {<br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div> ...</div><div><br></div><div><div style="text-align:start;text-indent:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div>if (is_method("INVITE") && !has_totag()) {</div><div>                ...</div></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div style="text-align:start;text-indent:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-transform:none;white-space:normal;word-spacing:0px">                # handle DR failure</div></div></div><div><div style="text-align:start;text-indent:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-transform:none;white-space:normal;word-spacing:0px">                t_on_failure("MANAGE_DR_FAILUR<wbr>E");</div></div></div><div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><br></div></div><div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">                if (!do_routing("$avp(drgroup)")) {</div></div><div><div style="text-align:start;text-indent:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-transform:none;white-space:normal;word-spacing:0px">                          sl_reply("503", "Unknown destination");</div></div></div><div><div style="text-align:start;text-indent:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-transform:none;white-space:normal;word-spacing:0px">                          exit;</div></div></div><div><div style="text-align:start;text-indent:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-transform:none;white-space:normal;word-spacing:0px">                 }</div></div></div><div><div style="text-align:start;text-indent:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-transform:none;white-space:normal;word-spacing:0px"><br></div></div></div><div><div style="text-align:start;text-indent:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div><div>                # Relay the request to gateway</div></div></div></div><div><div style="text-align:start;text-indent:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div><div>                route(DR_RELAY);</div></div></div></div><div><div style="text-align:start;text-indent:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-transform:none;white-space:normal;word-spacing:0px">}</div></div></div></blockquote><div>}</div><div><br></div><div><div># DR relay<br></div></div><div><div>route[DR_RELAY] {</div><div><br></div><div>        if (!route(RELAY)) {<br></div><div>                sl_reply_error();<br></div><div>        };</div><div>        exit;<br></div><div>}</div></div><div><br></div><div># DRouting failure route<br></div><div><div>failure_route[MANAGE_DR_FAILUR<wbr>E] {</div><div><br></div><div>        if (t_is_canceled()) {</div><div>                exit;<br></div><div>        }</div><div><br></div><div>        if (t_check_status("486|600")) {<br></div><div>                xlog("L_INFO", "received BUSY, stop trying"); 

<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"># -- curious, 486 gets relayed fine</span>

</div><div>                exit;<br></div><div>        }</div><div><br></div><div>        # try next GW</div><div>        if (use_next_gw()) {</div><div>                t_on_failure("MANAGE_DR_FAILUR<wbr>E");</div><div><br></div><div>                xlog("L_INFO", "MANAGE_DR_FAILURE: Call from <$fu> with username <$fU> going to <$ru>\n");<br></div><div>                route(RELAY);</div><div>                exit;</div><div><br></div><div>        # -- Trunk failover to PSTN number</div><div>        } else if (is_avp_set("$avp(s:failover)"<wbr>) && $avp(direction) == "in") {</div><div>                $ru="sip:" + $avp(s:failover) + "@<a href="http://someothergateway.com" target="_blank">someothergateway.com</a>"; # -- basic routing, to improve by sending back to DRouting with updated $rU<br></div><div>                xlog("L_INFO", "MANAGE_DR_FAILURE: No more gateways, sending call to trunk failover destination <$ru>...\n");</div><div>                route(RELAY);</div><div><br></div><div>        } else {<br></div><div>                xlog("L_WARN", "No more routes available\n");</div><div>                #t_reply ("503", "Service Unavailable");        # -- why do we have to force a reply instead of proxy relaying whatever it is<br></div><div>                exit;</div><div>        }</div><div>}</div></div><div><br></div><div><br></div></div><div class="m_3048362873888402812HOEnZb"><div class="m_3048362873888402812h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 14, 2018 at 11:34 AM, Alex Balashov <span dir="ltr"><<a href="mailto:abalashov@evaristesys.com" target="_blank">abalashov@evaristesys.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
1. Do you have a failure_route for this transaction? If so, can you provide it?<br>
<br>
2. Make sure the `failure_reply_mode` modparam for TM is set to 3, which<br>
is default anyway:<br>
<br>
<a href="https://kamailio.org/docs/modules/5.1.x/modules/tm.html#tm.p.failure_reply_mode" rel="noreferrer" target="_blank">https://kamailio.org/docs/modu<wbr>les/5.1.x/modules/tm.html#tm.p<wbr>.failure_reply_mode</a><br>
<br>
-- Alex<br>
<span><br>
On Mon, May 14, 2018 at 11:33:15AM -0400, Sergiu Pojoga wrote:<br>
<br>
> Not sure if it's a default Kamailio behavior or something I'm doing wrong...<br>
> <br>
> When receiving a negative reply for an INVITE (more like in the 5xx range),<br>
> proxy doesn't relay the message to the originator but instead issues it's<br>
> own "500 Service Unavailable".<br>
> <br>
> That doesn't happen, from observations so far, to "603 Declined" or "486<br>
> Busy Here" or "404 Not Found" or "200 OK" replies.<br>
> <br>
</span>> *For example, here's the negative reply proxy receives from the callee:*<br>
<span>> <br>
> 2018/05/14 10:52:37.716627 65.XX.XX.166:5060 -> 65.XX.XX.167:5060<br>
> SIP/2.0 503 Service Unavailable<br>
> Via: SIP/2.0/UDP<br>
> 65.xx.xx.167;branch=z9hG4bK922<wbr>3.00b4f3143d245a895c4bb6a107ad<wbr>d258.0;received=65.xx.xx.167;r<wbr>port=5060<br>
> Via: SIP/2.0/UDP<br>
> 205.xx.xx.221;received=205.xx.<wbr>xx.221;rport=5060;branch=z9hG4<wbr>bKQ4XpXga0vgZ8B<br>
> From: "514XXXXXXX" <sip: 514XXXXXXX @205.xx.xx.221>;tag=tXj0NHrje9<wbr>jNS<br>
> To: <sip:450XXXXXXX@65.xx.xx.167>;<wbr>tag=as18e452b7<br>
> Call-ID: 48eac296-d229-1236-a685-005056<wbr>a149a4<br>
> CSeq: 122818714 INVITE<br>
> Server: Asterisk<br>
> Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO,<br>
> PUBLISH, MESSAGE<br>
> Supported: replaces, timer<br>
> Session-Expires: 1800;refresher=uas<br>
> X-Asterisk-HangupCause: Subscriber absent<br>
> X-Asterisk-HangupCauseCode: 20<br>
> Content-Length: 0<br>
> <br>
</span>> *Here's what the originator gets in the final message:*<br>
<span>> <br>
> 2018/05/14 10:52:37.718143 65.xx.xx.167:5060 -> 205.xx.xx.221:5060<br>
> SIP/2.0 500 Service Unavailable<br>
> Via: SIP/2.0/UDP<br>
> 205.xx.xx.221;rport=5060;branc<wbr>h=z9hG4bKQ4XpXga0vgZ8B;receive<wbr>d=205.xx.xx.221<br>
> From: "514XXXXXXX" <sip:514XXXXXXX@205.xx.xx.221><wbr>;tag=tXj0NHrje9jNS<br>
> To: <sip:450XXXXXXX@65.xx.xx.167>;<wbr>tag=31a2c69b5d434ef4a60796e26f<wbr>568bf0-9343<br>
> Call-ID: 48eac296-d229-1236-a685-005056<wbr>a149a4<br>
> CSeq: 122818714 INVITE<br>
> Server: Kamailio 5.1<br>
> Content-Length: 0<br>
> <br>
> I'd like any reply to be relayed back as is, unless I do some<br>
> t_check_status() => t_reply() for specific reasons (which I have none at<br>
> this point).<br>
> <br>
> Thanks<br>
> Sergiu<br>
<br>
</span>> ______________________________<wbr>_________________<br>
> Kamailio (SER) - Users Mailing List<br>
> <a href="mailto:sr-users@lists.kamailio.org" target="_blank">sr-users@lists.kamailio.org</a><br>
> <a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">https://lists.kamailio.org/cgi<wbr>-bin/mailman/listinfo/sr-users</a><br>
<span class="m_3048362873888402812m_8363517306855056629HOEnZb"><font color="#888888"><br>
<br>
-- <br>
Alex Balashov | Principal | Evariste Systems LLC<br>
<br>
Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free) <br>
Web: <a href="http://www.evaristesys.com/" rel="noreferrer" target="_blank">http://www.evaristesys.com/</a>, <a href="http://www.csrpswitch.com/" rel="noreferrer" target="_blank">http://www.csrpswitch.com/</a><br>
<br>
______________________________<wbr>_________________<br>
Kamailio (SER) - Users Mailing List<br>
<a href="mailto:sr-users@lists.kamailio.org" target="_blank">sr-users@lists.kamailio.org</a><br>
<a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">https://lists.kamailio.org/cgi<wbr>-bin/mailman/listinfo/sr-users</a><br>
</font></span></blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
Kamailio (SER) - Users Mailing List<br>
<a href="mailto:sr-users@lists.kamailio.org" target="_blank">sr-users@lists.kamailio.org</a><br>
<a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">https://lists.kamailio.org/cgi<wbr>-bin/mailman/listinfo/sr-users</a><br>
<br></blockquote></div><br></div></div>