<div dir="ltr">          In this case ,in case of failure route , its not going inside the &quot;use_next_gw&quot; loop . Dont know whats wrong in my config file . <div>Please help me .</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><b><i>Thanks &amp; Regards</i></b><div><i>Sasmita Panda</i></div><div><i>Network Testing and Software Engineer</i></div><div><i>3CLogic , ph:07827611765</i></div></div></div></div>
<br><div class="gmail_quote">On Wed, Oct 7, 2015 at 6:56 PM, Sasmita Panda <span dir="ltr">&lt;<a href="mailto:spanda@3clogic.com" target="_blank">spanda@3clogic.com</a>&gt;</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 All ,<div><br></div><div>     I am using opensips-1.11 . I have some scenario in which there is two or more gateways corresponding to a single group .</div><div><br></div><div>     for example :</div><div><br></div><div>     grp id : 1 , domain : <a href="http://mongodb1.sasmita.com" target="_blank">mongodb1.sasmita.com</a></div><div>     gate ways : </div><div>      gw:1 , address : <a href="http://162.1.1.1:5090" target="_blank">162.1.1.1:5090</a></div><div>      gw:2 , address : <a href="http://162.10.1.1:5080" target="_blank">162.10.1.1:5080</a></div><div><br></div><div>   So , what I want is that when call get connected to gw1 , if its fail then call get routed to the next gateway . </div><div><br></div><div><br></div><div>   What I have done for this is bellow :</div><div><br></div><div><div>mysql&gt; select * from dr_groups;</div><div>+----+----------+-------------------------------+---------+--------------+</div><div>| id | username | domain                        | groupid | description  |</div><div>+----+----------+-------------------------------+---------+--------------+</div><div>|  1 |          | <a href="http://mongodb1.sasmita.com" target="_blank">mongodb1.sasmita.com</a>          |       9 | out          |</div><div>+----+----------+-------------------------------+---------+--------------+</div><div><br></div><div>mysql&gt; select * from dr_gateways;</div><div>+----+------+------+---------------------+-------+------------+-------+------------+-------+--------+--------------+</div><div>| id | gwid | type | address             | strip | pri_prefix | attrs | probe_mode | state | socket | description  |</div><div>+----+------+------+---------------------+-------+------------+-------+------------+-------+--------+--------------+</div><div>| 10 | 4    |    2 | <a href="http://162.1.1.1:5090" target="_blank">162.1.1.1:5090</a>      |     0 | NULL       | NULL  |          0 |     0 | NULL   | sipp one     |</div><div>|  8 | 2    |    2 | <a href="http://162.10.1.1:5080" target="_blank">162.10.1.1:5080</a>     |     0 | NULL       | NULL  |          0 |     0 | NULL   | asterisk     |</div><div>+----+------+------+---------------------+-------+------------+-------+------------+-------+--------+--------------+</div><div>mysql&gt;</div><div>mysql&gt; select * from dr_rules;</div><div>+--------+---------+--------+---------+----------+---------+--------+-------+---------------+</div><div>| ruleid | groupid | prefix | timerec | priority | routeid | gwlist | attrs | description   |</div><div>+--------+---------+--------+---------+----------+---------+--------+-------+---------------+</div><div>|     32 | 9       |        |         |        0 |         | 2      | NULL  | fail route    |</div><div>|     29 | 9       |        |         |        1 |         | 4      | NULL  | out           |</div><div>+--------+---------+--------+---------+----------+---------+--------+-------+---------------+</div></div><div><br></div><div>This is my table of content .</div><div><br></div><div>      In my opensips script I have done the bellow things .</div><div><br></div><div>Starting I have loaded all the modules . then the below things happening .</div><div>   I have loaded drouting and dialplan , inaddition to this all the necessary modules .</div><div>        </div><div><br></div><div><br></div><div><font color="#0b5394">route{</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">        </span>if (!mf_process_maxfwd_header(&quot;10&quot;)) {</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                </span>sl_send_reply(&quot;483&quot;,&quot;Too Many Hops&quot;);</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                </span>exit;</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">        </span>};</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">        </span>if (msg:len &gt;=  2048 ) {</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                </span>sl_send_reply(&quot;513&quot;, &quot;Message too big&quot;);</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                </span>exit;</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">        </span>};</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">        </span>if (method==&quot;SUBSCRIBE&quot;) {</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                </span>sl_send_reply(&quot;405&quot;, &quot;Method not allowed&quot;);</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                </span>exit;</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">        </span>}</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">        </span>if (method==&quot;NOTIFY&quot;) {</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                </span>sl_send_reply(&quot;405&quot;, &quot;Method not allowed&quot;);</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                </span>exit;</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">        </span>}</font></div><div><font color="#0b5394">        if (method==&quot;OPTIONS&quot;) {</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                </span>sl_send_reply(&quot;200&quot;, &quot;OK&quot;);</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                </span>exit;</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">        </span>}</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">        </span>if (!method==&quot;REGISTER&quot;)</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                </span>record_route();</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">        </span>if (loose_route()) {</font></div><div><font color="#0b5394">                setflag(2);</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                </span>route(1);</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">        </span>};</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">        </span>if (!uri==myself) {</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                </span># drop packets, look at orig file for original config</font></div><div><font color="#0b5394">                        route(1);</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                        </span>exit; </font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">        </span>}</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">        </span>if (uri==myself) {</font></div><div><font color="#0b5394">              <span style="white-space:pre-wrap">        </span>force_rport();</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394">                if ( is_method(&quot;REGISTER&quot;)) {</font></div><div><font color="#0b5394">                     </font></div><div><font color="#0b5394">                  if(($hdr(User-Agent)!~&quot;scanner&quot;)||($hdr(User-Agent)!~&quot;SJphone&quot;))   # to stop scanners</font></div><div><font color="#0b5394">                       { </font></div><div><span style="white-space:pre-wrap"><font color="#0b5394">                </font></span></div><div><font color="#0b5394">                      if(is_present_hf(&quot;X-Info&quot;))</font></div><div><font color="#0b5394">                       {</font></div><div><font color="#0b5394">                        $var(x)=$hdr(X-Info);</font></div><div><font color="#0b5394">                        $var(y)=$(var(x){s.select,0,;});</font></div><div><font color="#0b5394">                        $var(z)=$(var(x){s.select,1,;});</font></div><div><font color="#0b5394">                        $var(y)=$(var(y){s.select,1,=});</font></div><div><font color="#0b5394">                        $var(z)=$(var(z){s.select,1,=});</font></div><div><font color="#0b5394">                        if($(var(y){<a href="http://s.int" target="_blank">s.int</a>})!=0)</font></div><div><font color="#0b5394">                          {</font></div><div><font color="#0b5394">                              save(&quot;location&quot;,&quot;p1n$var(z)&quot;);</font></div><div><font color="#0b5394">                              exit;</font></div><div><font color="#0b5394">                         }else{</font></div><div><font color="#0b5394">                              save(&quot;location&quot;,&quot;rp1&quot;);</font></div><div><font color="#0b5394">                              append_to_reply(&quot;Contact: $ct \r\n&quot;);</font></div><div><font color="#0b5394">                              xlog( &quot;L_NOTICE&quot;, &quot;Contact &amp; $ct \n&quot; );</font></div><div><font color="#0b5394">                              sl_send_reply(&quot;200&quot;,&quot;OK&quot;);</font></div><div><font color="#0b5394">                              exit;</font></div><div><font color="#0b5394">                         }</font></div><div><font color="#0b5394">                       }else{</font></div><div><font color="#0b5394">                        save(&quot;location&quot;,&quot;p1n5&quot;);</font></div><div><font color="#0b5394">                        exit;</font></div><div><font color="#0b5394">                       }</font></div><div><font color="#0b5394">                       ; save(&quot;location&quot;,&quot;fc10p1&quot;);</font></div><div><font color="#0b5394">                        m_dump(&quot;$fu&quot;);</font></div><div><font color="#0b5394">                       }</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                        </span>exit;</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                </span>}</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394">    <span style="white-space:pre-wrap">        </span>    if ( is_method(&quot;CANCEL&quot;) )</font></div><div><font color="#0b5394">              {</font></div><div><font color="#0b5394">                if ( t_check_trans() ){</font></div><div><font color="#0b5394">                       t_relay();</font></div><div><font color="#0b5394">                   }</font></div><div><font color="#0b5394">                else { </font></div><div><font color="#0b5394">                       t_reply(&quot;200&quot;,&quot;OK&quot;); </font></div><div><font color="#0b5394">                   }    </font></div><div><font color="#0b5394">                 exit;</font></div><div><font color="#0b5394">               }</font></div><div><font color="#0b5394">   </font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394">                if (is_method(&quot;BYE&quot;)) {</font></div><div><font color="#0b5394">                    setflag(2);</font></div><div><font color="#0b5394">                    setflag(TRACE_FLAG);</font></div><div><font color="#0b5394">                    t_relay();</font></div><div><font color="#0b5394">                  exit;  </font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394">                }</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394">                if (is_method(&quot;INVITE&quot;)) {</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394">            setflag(4);</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                        </span>setflag(2);</font></div><div><font color="#0b5394">                xlog( &quot;L_NOTICE&quot;, &quot;CallCenter_Info &amp; $ci,$var(c) \n&quot; );</font></div><div><font color="#0b5394">                if(is_from_gw() ||  (to_uri=~&quot;@<a href="http://190.168.1.1" target="_blank">190.168.1.1</a>&quot;))</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                        </span>         {</font></div><div><font color="#0b5394">                    </font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">        </span>            xlog( &quot;L_WARN&quot;, &quot;Source IP sas : $Ri To Uri : $tu From : $fU Request URI: $oU Call ID:$ci&quot; );</font></div><div><font color="#0b5394">               </font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                        </span>    if ( !lookup(&quot;location&quot;)){</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                                </span>sl_send_reply(&quot;404&quot;,&quot;NO Match Found&quot;);</font></div><div><font color="#0b5394">                            exit;</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                </span>            }</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                        </span>    #do lcr</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                        </span>    if ( !serialize_branches(1)){</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                                </span>sl_send_reply(&quot;500&quot;,&quot;Internal Server Error&quot;);</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                                </span>exit;</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                        </span>    }</font></div><div><font color="#0b5394">                           else{</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                                </span>next_branches();</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                                </span>t_on_failure(&quot;3&quot;);</font></div><div><font color="#0b5394">                                route(1);</font></div><div><font color="#0b5394">                         <span style="white-space:pre-wrap">        </span>exit;<span style="white-space:pre-wrap">        </span></font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                        </span>     } </font></div><div><font color="#0b5394">                         }<span style="white-space:pre-wrap">        </span></font></div><div><font color="#0b5394">                       #}</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                        </span>else{</font></div><div><font color="#0b5394">                }</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                </span>}</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                </span>route(10);</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">        </span>};</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394">route[1] {</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">        </span>if (nat_uac_test(&quot;7&quot;)) {</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                </span>fix_nated_contact();</font></div><div><font color="#0b5394">        };</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">        </span>t_on_reply(&quot;1&quot;);</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">        </span>if (!t_relay()) {</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">                </span>sl_reply_error();</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">        </span>};</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">        </span>exit;</font></div><div><font color="#0b5394">}</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394">route[10] {</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394">$avp(src) = $rd;</font></div><div><font color="#0b5394">xlog(&quot;request domain,$avp(trl)&quot;);</font></div><div><font color="#0b5394">dp_translate(&quot;5&quot;, &quot;$avp(src)/$avp(trl)&quot;);</font></div><div><font color="#0b5394">$avp(grp)=$(avp(trl){<a href="http://s.int" target="_blank">s.int</a>});</font></div><div><font color="#0b5394">xlog(&quot;translated to  $avp(grp) \n&quot;);</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394">    if (!do_routing(&quot;$avp(grp)&quot;,&quot;F&quot;)) {</font></div><div><font color="#0b5394">        xlog(&quot;do_routing: No rules matching the URI\n&quot;);</font></div><div><font color="#0b5394">        send_reply(&quot;503&quot;,&quot;No rules matching the URI&quot;);</font></div><div><font color="#0b5394">        exit;</font></div><div><font color="#0b5394">    }</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394">    if (is_method(&quot;INVITE&quot;)) {</font></div><div><font color="#0b5394">        t_on_failure(&quot;10&quot;);</font></div><div><font color="#0b5394">    }</font></div><div><font color="#0b5394">    route(1);</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394">}</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394">onreply_route[1] {</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394">        if( status =~ &quot;18[0-9]&quot; ) {</font></div><div><font color="#0b5394">                t_on_failure(&quot;4&quot;);</font></div><div><font color="#0b5394">            }</font></div><div><font color="#0b5394"><span style="white-space:pre-wrap">        </span>if (nat_uac_test(&quot;1&quot;)) {</font></div><div><font color="#0b5394">                fix_nated_contact();</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394">          };</font></div><div><font color="#0b5394">}</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394">failure_route[10] {</font></div><div><font color="#0b5394">    xlog(&quot;DEBUG: DROUTING failure route active\n&quot;);</font></div><div><font color="#0b5394">     if (t_check_status(&quot;408|402|50[234]&quot;)) {</font></div><div><font color="#0b5394">                # route to the next gateway</font></div><div><font color="#0b5394">               xlog(&quot;DEBUG: DROUTING use next gateway \n&quot;); </font></div><div><font color="#0b5394">               if (use_next_gw()) {</font></div><div><font color="#0b5394">                        # prepare for lcr failover</font></div><div><font color="#0b5394">                        xlog( &quot;L_NOTICE&quot;, &quot;[$Tf] ACC: $ci Next gateway $fU -&gt; $tU via $rd\n&quot; );</font></div><div><font color="#0b5394">                        t_on_reply(&quot;1&quot;);</font></div><div><font color="#0b5394">                        t_on_failure(&quot;10&quot;);</font></div><div><font color="#0b5394">                        # send from 5060 for primus gateways</font></div><div><font color="#0b5394">                        if (!t_relay()){</font></div><div><font color="#0b5394">                                exit;</font></div><div><font color="#0b5394">                        }</font></div><div><font color="#0b5394">                } else {</font></div><div><font color="#0b5394">                        xlog( &quot;L_WARN&quot;, &quot;[$Tf] FR: $ci No more buscuits in the biscuit tin -&gt; 503.\n&quot; );</font></div><div><font color="#0b5394">                        t_reply(&quot;503&quot;, &quot;Service unavailable -- no more gateways&quot;);</font></div><div><font color="#0b5394">                        exit;</font></div><div><font color="#0b5394">                };</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394">        };</font></div><div><font color="#0b5394">        exit;</font></div><div><font color="#0b5394">}</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394">failure_route[4] {</font></div><div><font color="#0b5394">     xlog(&quot;L_NOTICE&quot;,&quot;could not complete&quot;);</font></div><div><font color="#0b5394">}</font></div><div><br></div><div><br></div><div>           I want to switch to the next gateway in the status codes defined in the failure route . But , now its not switching the gateway . Its just coming to the else loop and giving   503 error .  I think there is something missing in my script or in my dynamic routing table .     </div><div>     </div><div>    Please let me know if I need to change something . I am trying this from very long time but not getting any result . Any kind of help is appreciated .</div><div><br clear="all"><div><div><div dir="ltr"><b><i>Thanks &amp; Regards</i></b><span class="HOEnZb"><font color="#888888"><div><i>Sasmita Panda</i></div><div><i>Network Testing and Software Engineer</i></div><div><i>3CLogic , ph:07827611765</i></div></font></span></div></div></div>
</div></div>
</blockquote></div><br></div>