<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">mongodb1.sasmita.com</a></div><div> gate ways : </div><div> gw:1 , address : <a href="http://162.1.1.1:5090">162.1.1.1:5090</a></div><div> gw:2 , address : <a href="http://162.10.1.1:5080">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> select * from dr_groups;</div><div>+----+----------+-------------------------------+---------+--------------+</div><div>| id | username | domain | groupid | description |</div><div>+----+----------+-------------------------------+---------+--------------+</div><div>| 1 | | <a href="http://mongodb1.sasmita.com">mongodb1.sasmita.com</a> | 9 | out |</div><div>+----+----------+-------------------------------+---------+--------------+</div><div><br></div><div>mysql> 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">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">162.10.1.1:5080</a> | 0 | NULL | NULL | 0 | 0 | NULL | asterisk |</div><div>+----+------+------+---------------------+-------+------------+-------+------------+-------+--------+--------------+</div><div>mysql></div><div>mysql> 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 class="" style="white-space:pre">        </span>if (!mf_process_maxfwd_header("10")) {</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                </span>sl_send_reply("483","Too Many Hops");</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                </span>exit;</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">        </span>};</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394"><span class="" style="white-space:pre">        </span>if (msg:len >= 2048 ) {</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                </span>sl_send_reply("513", "Message too big");</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                </span>exit;</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">        </span>};</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394"><span class="" style="white-space:pre">        </span>if (method=="SUBSCRIBE") {</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                </span>sl_send_reply("405", "Method not allowed");</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                </span>exit;</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">        </span>}</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">        </span>if (method=="NOTIFY") {</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                </span>sl_send_reply("405", "Method not allowed");</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                </span>exit;</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">        </span>}</font></div><div><font color="#0b5394"> if (method=="OPTIONS") {</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                </span>sl_send_reply("200", "OK");</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                </span>exit;</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">        </span>}</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394"><span class="" style="white-space:pre">        </span>if (!method=="REGISTER")</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                </span>record_route();</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">        </span>if (loose_route()) {</font></div><div><font color="#0b5394"> setflag(2);</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                </span>route(1);</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">        </span>};</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394"><span class="" style="white-space:pre">        </span>if (!uri==myself) {</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                </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 class="" style="white-space:pre">                        </span>exit; </font></div><div><font color="#0b5394"><span class="" style="white-space:pre">        </span>}</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394"><span class="" style="white-space:pre">        </span>if (uri==myself) {</font></div><div><font color="#0b5394"> <span class="" style="white-space:pre">        </span>force_rport();</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394"> if ( is_method("REGISTER")) {</font></div><div><font color="#0b5394"> </font></div><div><font color="#0b5394"> if(($hdr(User-Agent)!~"scanner")||($hdr(User-Agent)!~"SJphone")) # to stop scanners</font></div><div><font color="#0b5394"> { </font></div><div><span class="" style="white-space:pre"><font color="#0b5394">                </font></span></div><div><font color="#0b5394"> if(is_present_hf("X-Info"))</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">s.int</a>})!=0)</font></div><div><font color="#0b5394"> {</font></div><div><font color="#0b5394"> save("location","p1n$var(z)");</font></div><div><font color="#0b5394"> exit;</font></div><div><font color="#0b5394"> }else{</font></div><div><font color="#0b5394"> save("location","rp1");</font></div><div><font color="#0b5394"> append_to_reply("Contact: $ct \r\n");</font></div><div><font color="#0b5394"> xlog( "L_NOTICE", "Contact & $ct \n" );</font></div><div><font color="#0b5394"> sl_send_reply("200","OK");</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("location","p1n5");</font></div><div><font color="#0b5394"> exit;</font></div><div><font color="#0b5394"> }</font></div><div><font color="#0b5394"> ; save("location","fc10p1");</font></div><div><font color="#0b5394"> m_dump("$fu");</font></div><div><font color="#0b5394"> }</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                        </span>exit;</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                </span>}</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394"> <span class="" style="white-space:pre">        </span> if ( is_method("CANCEL") )</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("200","OK"); </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("BYE")) {</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("INVITE")) {</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394"> setflag(4);</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                        </span>setflag(2);</font></div><div><font color="#0b5394"> xlog( "L_NOTICE", "CallCenter_Info & $ci,$var(c) \n" );</font></div><div><font color="#0b5394"> if(is_from_gw() || (to_uri=~"@<a href="http://190.168.1.1">190.168.1.1</a>"))</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                        </span> {</font></div><div><font color="#0b5394"> </font></div><div><font color="#0b5394"><span class="" style="white-space:pre">        </span> xlog( "L_WARN", "Source IP sas : $Ri To Uri : $tu From : $fU Request URI: $oU Call ID:$ci" );</font></div><div><font color="#0b5394"> </font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                        </span> if ( !lookup("location")){</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                                </span>sl_send_reply("404","NO Match Found");</font></div><div><font color="#0b5394"> exit;</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                </span> }</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                        </span> #do lcr</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                        </span> if ( !serialize_branches(1)){</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                                </span>sl_send_reply("500","Internal Server Error");</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                                </span>exit;</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                        </span> }</font></div><div><font color="#0b5394"> else{</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                                </span>next_branches();</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                                </span>t_on_failure("3");</font></div><div><font color="#0b5394"> route(1);</font></div><div><font color="#0b5394"> <span class="" style="white-space:pre">        </span>exit;<span class="" style="white-space:pre">        </span></font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                        </span> } </font></div><div><font color="#0b5394"> }<span class="" style="white-space:pre">        </span></font></div><div><font color="#0b5394"> #}</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                        </span>else{</font></div><div><font color="#0b5394"> }</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                </span>}</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                </span>route(10);</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394"><span class="" style="white-space:pre">        </span>};</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394">route[1] {</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">        </span>if (nat_uac_test("7")) {</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                </span>fix_nated_contact();</font></div><div><font color="#0b5394"> };</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">        </span>t_on_reply("1");</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">        </span>if (!t_relay()) {</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">                </span>sl_reply_error();</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">        </span>};</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394"><span class="" style="white-space:pre">        </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("request domain,$avp(trl)");</font></div><div><font color="#0b5394">dp_translate("5", "$avp(src)/$avp(trl)");</font></div><div><font color="#0b5394">$avp(grp)=$(avp(trl){<a href="http://s.int">s.int</a>});</font></div><div><font color="#0b5394">xlog("translated to $avp(grp) \n");</font></div><div><font color="#0b5394"><br></font></div><div><font color="#0b5394"> if (!do_routing("$avp(grp)","F")) {</font></div><div><font color="#0b5394"> xlog("do_routing: No rules matching the URI\n");</font></div><div><font color="#0b5394"> send_reply("503","No rules matching the URI");</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("INVITE")) {</font></div><div><font color="#0b5394"> t_on_failure("10");</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 =~ "18[0-9]" ) {</font></div><div><font color="#0b5394"> t_on_failure("4");</font></div><div><font color="#0b5394"> }</font></div><div><font color="#0b5394"><span class="" style="white-space:pre">        </span>if (nat_uac_test("1")) {</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("DEBUG: DROUTING failure route active\n");</font></div><div><font color="#0b5394"> if (t_check_status("408|402|50[234]")) {</font></div><div><font color="#0b5394"> # route to the next gateway</font></div><div><font color="#0b5394"> xlog("DEBUG: DROUTING use next gateway \n"); </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( "L_NOTICE", "[$Tf] ACC: $ci Next gateway $fU -> $tU via $rd\n" );</font></div><div><font color="#0b5394"> t_on_reply("1");</font></div><div><font color="#0b5394"> t_on_failure("10");</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( "L_WARN", "[$Tf] FR: $ci No more buscuits in the biscuit tin -> 503.\n" );</font></div><div><font color="#0b5394"> t_reply("503", "Service unavailable -- no more gateways");</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("L_NOTICE","could not complete");</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 class="gmail_signature"><div dir="ltr"><b><i>Thanks & 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>
</div></div>