Hello,<br><br>I am not an extensive user of lcr module, but probably next_gw() adds a branch each time is called in failure route.<br><br>If yes (when true you should see some parallel forking, depending o how the addresses are selected), you can mark the &quot;bad&quot; branches with a branch flag and drop them in a branch_route.<br>
<br>        while(next_gw()){<br>            if($var(gw_flag) != $avp(i:712)){<br>
                xlog(&quot;L_INFO&quot;,&quot;Found an LCR destination which is different than current, routing. ($ci)&quot;);<br>                t_on_reply(&quot;1&quot;);<br>                t_on_failure(&quot;1&quot;);<br>
                t_on_branch(&quot;1&quot;);<br>
                t_relay();<br>                exit;<br>            }else{<br>                xlog(&quot;L_INFO&quot;,&quot;The next destination in LCR has the same AVP flag, skipping. ($ci)&quot;);  <br>                setbflag(10);<br>
            }<br>        }<br><br><br>branch_route[1] {<br>   if(isbflagset(10))<br>       drop;<br>}<br><br>However, if the destinations are selected like provider 1, provider 2, provider 1, provider 2, the condition you have in config file failure route is not good, since you check for change of the provider in each step, which happens in this case. Maybe you can use flags to check if a provider was used (or avps).<br>
<br>Cheers,<br>Daniel<br><br><div class="gmail_quote">On Tue, Mar 8, 2011 at 11:35 PM, Geoffrey Mina <span dir="ltr">&lt;<a href="mailto:geoffreymina@gmail.com">geoffreymina@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hello,<br>I have a question about LCR which I have been unable to solve.  I have 4 upstream carrier gateways owned by 2 carriers.  Each carrier provides a primary and secondary gateway for load balancing purposes.  On a 5XX error I am trying to send the same call to the other carrier.  If both carriers reject the call with 5XX, I allow the response to go downstream to my asterisk server.  The issue I am running into is that in a scenario where both my carriers respond with a 5XX, I end up presenting the same call to all 4 gateways.  I would like to present the call to one gateway on each carrier and not try the same carriers second gateway for the same call.  Here is what is happening now:<br>

<br>ASTERISK --&gt; INVITE --&gt; KAMAILIO<br>INVITE --&gt; CARRIER A/GATEWAY 1 &lt;-- 5XX Error<br>INVITE --&gt; CARRIER A/GATEWAY 2 &lt;-- 5XX Error<br>INVITE --&gt; CARRIER B/GATEWAY 1 &lt;-- 5XX Error<br>INVITE --&gt; CARRIER B/GATEWAY 2 &lt;-- 5XX Error<br>

KAMAILIO --&gt; 5XX Error --&gt; ASTERISK<br><br>OR any combination of the above... i.e.<br><br>ASTERISK --&gt; INVITE --&gt; KAMAILIO<br>
INVITE --&gt; CARRIER A/GATEWAY 1 &lt;-- 5XX Error<br>
INVITE --&gt; CARRIER B/GATEWAY 2 &lt;-- 5XX Error<br>
INVITE --&gt; CARRIER B/GATEWAY 1 &lt;-- 5XX Error<br>
INVITE --&gt; CARRIER A/GATEWAY 2 &lt;-- 5XX Error<br>
KAMAILIO --&gt; 5XX Error --&gt; ASTERISK<br><br><br>What I want to happen is:<br><br>ASTERISK --&gt; INVITE --&gt; KAMAILIO<br>
INVITE --&gt; CARRIER A/GATEWAY 1 or 2 &lt;-- 5XX Error<br>
INVITE --&gt; CARRIER B/GATEWAY 1 or 2 &lt;-- 5XX Error<br>
KAMAILIO --&gt; 5XX Error --&gt; ASTERISK<br><br>I tried dealing with the issue using some flags on the gateway, but i couldn&#39;t get the logic to work properly.  Here is the path I was heading down, but my plan fell apart after some testing.<br>

<br>CARRIER A has a gateway flag of &quot;1&quot;<br>CARRIER B has a gateway flag of &quot;2&quot;<br><br>failure_route[1]{<br>       $var(gw_flag) = $avp(i:712);<br>        <br>        while(next_gw()){<br>            if($var(gw_flag) != $avp(i:712)){<br>

                xlog(&quot;L_INFO&quot;,&quot;Found an LCR destination which is different than current, routing. ($ci)&quot;);<br>                t_on_reply(&quot;1&quot;);<br>                t_on_failure(&quot;1&quot;);<br>

                t_relay();<br>                exit;<br>            }else{<br>                xlog(&quot;L_INFO&quot;,&quot;The next destination in LCR has the same AVP flag, skipping. ($ci)&quot;);  <br>            }<br>
        }<br>
        <br>        # let the reply go upstram - it is the default action<br>        xlog(&quot;L_ERR&quot;, &quot;No Next Gateway - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n&quot;);<br>        exit;<br>}<br><br><br>Any help would be greatly appreciated.<br>

<br>Thanks,<br>Geoff<br>
<br>_______________________________________________<br>
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>
<a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Daniel-Constantin Mierla<br>  <a href="http://www.asipto.com">http://www.asipto.com</a><br>