Greetings Bogdan;<br><br>Unfortunately there&#39;s a minor hitch in the getalong with this suggestion - the failure route utilises two functions that can only be called from a failure_route block (t_was_cancelled() and ds_next_domain()).<br>
<br>From my understanding of what you&#39;re suggesting below, I should move my failure logic into its own route block and then call it, both from the failure_route block and from the t_relay() failed section. This would be a very elegant way to handle it, if I could use it :)<br>
<br>It appears there is no &#39;back door&#39; method of calling a failure_route() block from inside a route block, as in:<br>if (!t_relay()) {<br>    failure_route(&quot;2&quot;);<br>    }<br><br>Any new thoughts?<br><br>
Many thanks, both of you.<br><br> - JP<br><br><br><div class="gmail_quote">On Fri, Apr 2, 2010 at 2:58 AM, Bogdan-Andrei Iancu <span dir="ltr">&lt;<a href="mailto:bogdan@voice-system.ro">bogdan@voice-system.ro</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi Jock,<br>
<br>
I guess the problem is detecting the failure . The failure route catches<br>
only SIP failures (like you sent the requests and you get nothing or<br>
negative reply); but failure route does not catch sending error (like in<br>
your case).<br>
<br>
So, you should do something like:<br>
<br>
route[try_next] {<br>
    here put the next stuff<br>
}<br>
<br>
<br>
{<br>
    ...<br>
    t_on_failure(&quot;sip_failure&quot;);<br>
<div class="im">    if (!t_relay()) {<br>
        xlog(&quot;L_WARN&quot;, &quot;[$Tf] t_relay fail\n&quot;);<br>
</div>        route(try_next);<br>
    }<br>
    ...<br>
}<br>
<br>
<br>
failure_route[sip_failure]<br>
{<br>
    if (t_check_status(&quot;....&quot;) {<br>
       # is a destination failure<br>
       route(try_next);<br>
    }<br>
}<br>
<br>
<br>
Regards,<br>
bogdan<br>
<div class="im"><br>
<br>
Jock McKechnie wrote:<br>
&gt;<br>
&gt;<br>
&gt; On Thu, Apr 1, 2010 at 10:26 AM, Brett Nemeroff &lt;<a href="mailto:brett@nemeroff.com">brett@nemeroff.com</a><br>
</div><div><div></div><div class="h5">&gt; &lt;mailto:<a href="mailto:brett@nemeroff.com">brett@nemeroff.com</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;     Where is your failure route? :)<br>
&gt;     -Brett<br>
&gt;<br>
&gt;<br>
&gt; I intentionally chose to not include it, along with the other 200<br>
&gt; lines of config, for simplicity, but you&#39;re right, given this is a<br>
&gt; failure, I clearly should&#39;ve, duh :)<br>
&gt;<br>
&gt; failure_route[2] {<br>
&gt;         if (t_was_cancelled()) {<br>
&gt;                 xlog( &quot;L_NOTICE&quot;, &quot;[$Tf] FR: transaction cancelled -<br>
&gt; exiting\n&quot; );<br>
&gt;                 exit;<br>
&gt;                 }<br>
&gt;<br>
&gt;         # If fr_timer expires t_check_status(&quot;408&quot;) is true, although<br>
&gt; $rs is &lt;null&gt;<br>
&gt;          if( t_check_status(&quot;408&quot;) ){<br>
&gt;                 xlog( &quot;L_NOTICE&quot;, &quot;[$Tf] FR: $ci -- TIMEOUT for<br>
&gt; Gateway $rd\n&quot; );<br>
&gt;          } else {<br>
&gt;                 xlog( &quot;L_NOTICE&quot;, &quot;[$Tf] FR: $ci -- $rs reason $rr\n&quot; );<br>
&gt;                 }<br>
&gt;<br>
&gt;         # 403 -- typically ISDN network says &#39;not a valid number&#39; etc..<br>
&gt;         if( t_check_status(&quot;403&quot;) ){<br>
&gt;                 xlog(&quot;L_WARN&quot;, &quot;[$Tf] FR: $ci -- SIP-$rs Forbidden -&gt;<br>
&gt; ISDN Cause Code 1\n&quot; );<br>
&gt;                 return;<br>
&gt;                 }<br>
&gt;<br>
&gt;         if( ds_next_domain() ){<br>
&gt;                 xlog( &quot;L_NOTICE&quot;, &quot;[$Tf] FR: $ci Next gateway $fU -&gt;<br>
&gt; $tU via $rd \n&quot; );<br>
&gt;<br>
&gt;                 t_on_failure(&quot;2&quot;);<br>
&gt;<br>
&gt;                 if( !t_relay() ){<br>
&gt;                         xlog( &quot;L_WARN&quot;, &quot;[$Tf] FR: $ci -- ERROR -<br>
&gt; Cannot t_relay() -- $fU -&gt; $tU via $rd\n&quot; );<br>
&gt;                         return;<br>
&gt;                         }<br>
&gt;                 return;<br>
&gt;         } else {<br>
&gt;                 xlog( &quot;L_WARN&quot;, &quot;[$Tf] FR: $ci No more gateways -&gt;<br>
&gt; 503.\n&quot; );<br>
&gt;                 t_reply(&quot;503&quot;, &quot;Service unavailable -- no more<br>
&gt; gateways&quot; );<br>
&gt;                 return;<br>
&gt;                 }<br>
&gt;<br>
&gt;         }<br>
&gt;<br>
&gt;  - Jock<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;     On Thu, Apr 1, 2010 at 11:20 AM, Jock McKechnie<br>
</div></div><div><div></div><div class="h5">&gt;     &lt;<a href="mailto:jock.mckechnie@gmail.com">jock.mckechnie@gmail.com</a> &lt;mailto:<a href="mailto:jock.mckechnie@gmail.com">jock.mckechnie@gmail.com</a>&gt;&gt; wrote:<br>

&gt;     &gt; Greetings all;<br>
&gt;     &gt;<br>
&gt;     &gt; I&#39;m attempting to set up a fail-over only scenario using<br>
&gt;     dispatcher and am<br>
&gt;     &gt; encountering some problems. I&#39;m using dispatcher since we&#39;re already<br>
&gt;     &gt; utilising it for load balancing, so it makes sense to reuse the<br>
&gt;     tool, and<br>
&gt;     &gt; according to the OpenSIPS 1.6 dispatcher module documentation it<br>
&gt;     supports<br>
&gt;     &gt; fail-over.<br>
&gt;     &gt;<br>
&gt;     &gt; If the destination server is running, everything works as<br>
&gt;     expected - algo 8<br>
&gt;     &gt; (which OpenSIPS logs as not found and defaulting to the first<br>
&gt;     entry) pushes<br>
&gt;     &gt; the call to the first server at all times. However if I block<br>
&gt;     the route to<br>
&gt;     &gt; the destination server like so:<br>
&gt;     &gt; /sbin/route add -host 192.168.0.99 reject<br>
&gt;     &gt; Then instead of failing over I get a SIP 477 (Send failed) error.<br>
&gt;     &gt;<br>
&gt;     &gt; The chunk of routing looks like so:<br>
&gt;     &gt;<br>
&gt;     &gt; xlog(&quot;L_WARN&quot;, &quot;[$Tf] Found failover, working on set: 1101\n&quot;);<br>
&gt;     &gt; if (!ds_select_domain(&quot;1101&quot;, &quot;8&quot;)) {<br>
&gt;     &gt;     t_reply(&quot;503&quot;, &quot;Unable to locate failover set requested&quot;);<br>
&gt;     &gt;     return;<br>
&gt;     &gt;     };<br>
&gt;     &gt;<br>
&gt;     &gt; route(1);<br>
&gt;     &gt; };<br>
&gt;     &gt;<br>
&gt;     &gt; route[1] {<br>
&gt;     &gt; t_on_failure(&quot;2&quot;);<br>
&gt;     &gt;<br>
&gt;     &gt; xlog(&quot;L_WARN&quot;, &quot;Attempting to relay call to $ru\n&quot;);<br>
&gt;     &gt;<br>
&gt;     &gt; if (!t_relay()) {<br>
&gt;     &gt;     xlog(&quot;L_WARN&quot;, &quot;[$Tf] t_relay fail\n&quot;);<br>
&gt;     &gt;     return;<br>
&gt;     &gt;     }<br>
&gt;     &gt; return;<br>
&gt;     &gt; }<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt; The log contains:<br>
&gt;     &gt; [Thu Apr  1 11:14:35 2010] Found failover, working on set: 1101<br>
&gt;     &gt; WARNING:dispatcher:ds_select_dst: algo 8 not implemented - using<br>
&gt;     first<br>
&gt;     &gt; entry...<br>
&gt;     &gt; Attempting to relay call to <a href="http://sip:+12125551212@192.168.0.99:5060" target="_blank">sip:+12125551212@192.168.0.99:5060</a><br>
</div></div>&gt;     &lt;<a href="http://sip:+12125551212@192.168.0.99:5060" target="_blank">http://sip:+12125551212@192.168.0.99:5060</a>&gt;<br>
<div class="im">&gt;     &gt; ERROR:core:udp_send:<br>
&gt;     sendto(sock,0xb3b9bd28,1039,0,0xb3ba2cf4,16): Network<br>
&gt;     &gt; is unreachable(101)<br>
&gt;     &gt; ERROR:tm:msg_send: udp_send failed<br>
&gt;     &gt; ERROR:tm:t_forward_nonack: sending request failed<br>
&gt;     &gt; [Thu Apr  1 11:14:35 2010] Found failover, working on set: 1101<br>
&gt;     &gt; WARNING:dispatcher:ds_select_dst: algo 8 not implemented - using<br>
&gt;     first<br>
&gt;     &gt; entry...<br>
&gt;     &gt; Attempting to relay call to <a href="http://sip:+12125551212@192.168.0.99:5060" target="_blank">sip:+12125551212@192.168.0.99:5060</a><br>
</div>&gt;     &lt;<a href="http://sip:+12125551212@192.168.0.99:5060" target="_blank">http://sip:+12125551212@192.168.0.99:5060</a>&gt;<br>
<div class="im">&gt;     &gt;<br>
&gt;     &gt; This suggests to me that instead of failing over it&#39;s simply<br>
&gt;     retrying the<br>
&gt;     &gt; first entry, which it shouldn&#39;t be, and after finding it out for<br>
&gt;     a second<br>
&gt;     &gt; time (and thus exhausting the two-entry set), gives up.<br>
&gt;     &gt;<br>
&gt;     &gt; Any thoughts?<br>
&gt;     &gt;<br>
&gt;     &gt;  - JP<br>
&gt;     &gt;<br>
&gt;     &gt; _______________________________________________<br>
&gt;     &gt; Users mailing list<br>
</div>&gt;     &gt; <a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a> &lt;mailto:<a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>&gt;<br>
<div class="im">&gt;     &gt; <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;<br>
&gt;     _______________________________________________<br>
&gt;     Users mailing list<br>
</div>&gt;     <a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a> &lt;mailto:<a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>&gt;<br>
<div class="im">&gt;     <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
&gt;<br>
&gt;<br>
&gt; ------------------------------------------------------------------------<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Users mailing list<br>
&gt; <a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
&gt; <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
&gt;<br>
<br>
<br>
</div><font color="#888888">--<br>
Bogdan-Andrei Iancu<br>
<a href="http://www.voice-system.ro" target="_blank">www.voice-system.ro</a><br>
</font><div><div></div><div class="h5"><br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
</div></div></blockquote></div><br>