<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>23 aug 2013 kl. 12:13 skrev Steve Davies <<a href="mailto:steve@connection-telecom.com">steve@connection-telecom.com</a>>:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On 23 August 2013 11:18, Steve Davies <span dir="ltr"><<a href="mailto:steve@connection-telecom.com" target="_blank">steve@connection-telecom.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Here's what I put in RELAY route block:<br>
<div class="gmail_extra"><div class="gmail_quote"><div><br></div><div><div style="margin: 0px; font-size: 12px; font-family: Inconsolata; ">
        $var(rr) = t_relay();</div><div style="margin: 0px; font-size: 12px; font-family: Inconsolata; ">        xlog("L_NOTICE","SLD: in RELAY, t_relay returned $var(rr)\n");</div><div style="margin: 0px; font-size: 12px; font-family: Inconsolata; ">        if (!$var(rr)) {</div><div style="margin: 0px; font-size: 12px; font-family: Inconsolata; ">                sl_reply_error();</div><div style="margin: 0px; font-size: 12px; font-family: Inconsolata; ">        }</div><div style="margin: 0px; font-size: 12px; font-family: Inconsolata; "><br></div><div style="margin: 0px; font-size: 12px; font-family: Inconsolata; "><br></div></div><div>In 4.0.3, t_relay gives a -1 in the case that there is a physical network issue (in my test I have a "-j DROP" iptables rule)</div>

<div><br></div></div></div></div></blockquote><div><br></div><div>Trying to find a way to detect the case where t_relay fails but doesn't call the failure block.  I dumped some hopeful looking pseudo variables, and tried to use an avp to communicate from the failure branch back to the relay point.</div>
<div><br></div><div>I tried this:</div><div><br></div><div>        $avp(senttoast) = 0;</div><div>        $var(rr) = t_relay();</div><div>        xlog("L_NOTICE","SLD: in RELAY, t_relay returned $var(rr) err.rcode is $err.rcode t_r_c is $T_reply_code sent = $avp(senttoast)\n");</div>
<div>        if ($var(rr) < 0) {</div><div>                sl_reply_error();</div><div>        }</div><div><br></div><div>and in my failure block I set $avp(senttoast) to 1.</div><div><br></div><div><br></div><div>I get:</div>
<div><br></div><div>Aug 23 12:07:02 ubuntu /usr/local/sbin/kamailio[7819]: NOTICE: <script>: SLD: in RELAY, t_relay returned -1 err.rcode is <null> t_r_c is 100 sent = 0</div><div><br></div><div>In the case of a 477 being sent back.  So I can't find anything distinctive so far.</div>
<div><br></div><div>In the case of a soft failure (I have the upstream send a 500):</div><div><br></div><div><div>Aug 23 12:09:32 ubuntu /usr/local/sbin/kamailio[7817]: NOTICE: <script>: SLD: in RELAY, t_relay returned 1 err.rcode is <null> t_r_c is 100 sent = 0</div>
</div><div><br></div><div>So the same.</div><div><br></div><div>From the trace I can see that the failure block is only executed after the t_relay returns.  The failure block runs on a different pid.</div><div><br></div><div>
<div>So there is a race.  Or maybe the avp doesn't work across branches or something?</div></div><div><br></div><div>Clues would be welcome!</div></div></div></div></blockquote><br></div><div>THe failure route is executed when a transaction fails, i.e. ends with a code higher than 299.</div><div><br></div><div>The failure of t_relay happens when you try to send to something that doesn't exist or something similar.</div><div><br></div><div>set </div><div><br></div><div>$du="<a href="sip:127.0.0.2:1234;transport=udp">sip:127.0.0.2:1234;transport=udp</a>";</div><div><br></div><div>and run t_relay to get an error. Or </div><div><br></div><div>$du="<a href="sip:steve.davies.learns.kamailio@jburg.example.com;transport=udp">sip:steve.davies.learns.kamailio@jburg.example.com;transport=udp</a>";</div><div><br></div><div>(for DNS errors)</div><div><br></div><div>or</div><div><br></div><div>$du = "<a href="sip:david.duffet@www.digium.com:80;transport=tcp">sip:david.duffet@www.digium.com:80;transport=tcp</a>";</div><div><br></div><div>(for connection errors).</div><div><br></div><div>Test with those to see different behaviours.</div><div><br></div><div>/O</div><br></body></html>