<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta content="text/html;charset=UTF-8" http-equiv="Content-Type"></head><body ><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt;"><div>Thank you for the tip, Ben. <br><br>Do you by chance have a script snipped for this scenario? <br><br>For some reason, the drouting part: </div><div> if (!do_routing(0,"F")) {<br></div><div> xlog("DRoute GATEWAY: Failed. source:$si -$fU -> $rU\n");<br></div><div> send_reply(500, "No Gateway to Route found");<br></div><div> exit;<br></div><div> }<br></div><div> xlog("Before Entering Relay\n CarrierID_avp: $avp(carrier_id), GW ID avp: $avp(gw_id)");<br></div><div> route(relay);<br></div><div><br></div><div>Both AVPs return a single value instead of the a list for me, so I must be missing something.<br></div><div><br></div><div><br></div><div>Thanks.<br></div><div><br><br><br><div data-zbluepencil-ignore="true" style="" class="zmail_extra"><br><div id="Zm-_Id_-Sgn1">---- On Wed, 29 Apr 2020 14:50:38 -0400 <b>Ben Newlin <<a target="_blank" href="mailto:Ben.Newlin@genesys.com">Ben.Newlin@genesys.com</a>></b> wrote ----<br></div><br><blockquote style="border-left: 1px solid rgb(204, 204, 204); padding-left: 6px; margin: 0px 0px 0px 5px;"><div class=" zm_1460509428069829043_parse_-4529162983953911386"><div class="x_-1232250057WordSection1"><p class="MsoNormal">We also had a need to do this and did not find a way to do it via drouting directly, but it will work with drouting with a little help.<br></p><p class="MsoNormal"> <br></p><p class="MsoNormal">First, we specify the carrier_id_avp param [1]. After we call do_routing, we copy out the carrier IDs from that avp into our own AVP. Then we use route_to_carrier [2] for each carrier ID in the list. To continue routing within the carrier,
you can still do use_next_gw. When that returns false (no more gateways), or if you want to skip to the next carrier you just call route_to_carrier again with the next ID in your list.<br></p><p class="MsoNormal"> <br></p><p class="MsoNormal">This solved two problem for us:<br></p><p class="MsoNormal">* allows us to fail over by carrier instead of just by gateway<br></p><p class="MsoNormal">* allows us to call do_routing multiple times for a call with different groups and aggregate the results<br></p><p class="MsoNormal"> <br></p><p class="MsoNormal">[1] - <a target="_blank" href="https://opensips.org/docs/modules/3.0.x/drouting.html#param_carrier_id_avp"> https://opensips.org/docs/modules/3.0.x/drouting.html#param_carrier_id_avp</a><br></p><p class="MsoNormal">[2] - <a target="_blank" href="https://opensips.org/docs/modules/3.0.x/drouting.html#func_route_to_carrier"> https://opensips.org/docs/modules/3.0.x/drouting.html#func_route_to_carrier</a><br></p><p class="MsoNormal"> <br></p><p class="MsoNormal"> <br></p><div><p class="MsoNormal"><span class="colour" style="color:black">Ben Newlin</span><br></p></div><p class="MsoNormal"> <br></p><div style="border: none;border-top: solid rgb(181,196,223) 1.0pt;padding: 3.0pt 0.0in 0.0in 0.0in;"><p class="MsoNormal"><b><span class="colour" style="color:black"><span class="size" style="font-size:12pt">From: </span></span></b><span class="colour" style="color:black"><span class="size" style="font-size:12pt">Users <<a target="_blank" href="mailto:users-bounces@lists.opensips.org">users-bounces@lists.opensips.org</a>> on behalf of Alex A <<a target="_blank" href="mailto:alex.a@gtanetworkconsulting.com">alex.a@gtanetworkconsulting.com</a>><br> <b>Reply-To: </b>OpenSIPS users mailling list <<a target="_blank" href="mailto:users@lists.opensips.org">users@lists.opensips.org</a>><br> <b>Date: </b>Wednesday, April 29, 2020 at 2:40 PM<br> <b>To: </b>users <<a target="_blank" href="mailto:users@lists.opensips.org">users@lists.opensips.org</a>><br> <b>Subject: </b>[OpenSIPS-Users] Drouting failover by carrier only</span></span></p></div><div><p class="MsoNormal"> <br></p></div><div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt">Hi Everyone,</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> </span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt">Is it possible to failover to next carrier (instead next gateway) while using drouting?</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> </span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> </span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt">I got the below to work; however currently, use_next_gw gets the next gateway in the list, so</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt">if gwlist= #0,#3 </span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> </span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt">and one of the carriers has multiple gateway IPs, the retry happens many times to the same carrier:</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> </span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> </span></span><br></p></div><div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt">route[droute] {</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> </span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> xlog("DRoute GATEWAY: source:$si - $fU -> $rU\n");</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> if (!do_routing(0,"F")) {</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> xlog("DRoute GATEWAY: Failed. source:$si -$fU -> $rU\n");</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> send_reply(500, "No Gateway to Route found");</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> exit;</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> }</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> route(relay);</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> exit;</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> </span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> }</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> </span></span><br></p></div></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt">route[relay] {</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> </span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> if (is_method("INVITE")) {</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> t_on_failure("missed_call");</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> }</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> </span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> if (!t_relay()) {</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> if (use_next_gw()) {</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> xlog("L_INFO","Next Gateway: From=$fu, To=$tu,RU=$ru, CI=$ci IP=$si\n");</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> t_on_failure("missed_call");</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> route(relay);</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> exit;</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> }</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> else {</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> send_reply(503, "Service not available, no more gws");</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> exit;</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> }</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> };</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> exit;</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt">}</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> </span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> </span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt">failure_route[missed_call] {</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> </span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> #if (use_next_gw(, , $var(carrier_attrs))) {</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> if (use_next_gw(, $avp(gw_id),$avp(carrier_id))) {</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> xlog("MissedCall--Next Gateway: From=$fu, To=$tu,RU=$ru, CI=$ci IP=$si\n");</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> xlog("Carrier attributes of current gateway: $avp(gw_id). carrier: $avp(carrier_id)\n");</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> </span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> t_on_failure("missed_call");</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> route(relay);</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> exit;</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> }</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> else {</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> send_reply(503, "Service not available, no more gws");</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> exit;</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> }</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> </span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> </span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> </span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> </span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt">Thank you.</span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> </span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> </span></span><br></p></div><div><p class="MsoNormal"><span class="font" style="font-family:Verdana, sans-serif"><span class="size" style="font-size:10pt"> </span></span><br></p></div></div><p class="MsoNormal"><br><br></p></div></div>_______________________________________________<br>Users mailing list<br><a target="_blank" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br><a target="_blank" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br></blockquote></div></div><style><br></style><div><br></div></div><br></body></html>