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.

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.

This solved two problem for us:
* allows us to fail over by carrier instead of just by gateway
* allows us to call do_routing multiple times for a call with different groups 
and aggregate the results

[1] - https://opensips.org/docs/modules/3.0.x/drouting.html#param_carrier_id_avp
[2] - 
https://opensips.org/docs/modules/3.0.x/drouting.html#func_route_to_carrier


Ben Newlin

From: Users <users-boun...@lists.opensips.org> on behalf of Alex A 
<ale...@gtanetworkconsulting.com>
Reply-To: OpenSIPS users mailling list <users@lists.opensips.org>
Date: Wednesday, April 29, 2020 at 2:40 PM
To: users <users@lists.opensips.org>
Subject: [OpenSIPS-Users] Drouting failover by carrier only

Hi Everyone,

Is it possible to failover to next carrier (instead next gateway) while using 
drouting?


I got the below to work; however currently, use_next_gw gets the next gateway 
in the list, so
if gwlist= #0,#3

and one of the carriers has multiple gateway IPs, the retry happens many times 
to the same carrier:


route[droute] {

        xlog("DRoute GATEWAY: source:$si - $fU -> $rU\n");
        if (!do_routing(0,"F")) {
                xlog("DRoute GATEWAY: Failed. source:$si -$fU -> $rU\n");
                send_reply(500, "No Gateway to Route found");
                exit;
        }
        route(relay);
        exit;

        }

route[relay] {

        if (is_method("INVITE")) {
                t_on_failure("missed_call");
        }

        if (!t_relay()) {
                if (use_next_gw()) {
                      xlog("L_INFO","Next Gateway: From=$fu, To=$tu,RU=$ru, 
CI=$ci IP=$si\n");
                      t_on_failure("missed_call");
                      route(relay);
                      exit;
                }
                else {
                        send_reply(503, "Service not available, no more gws");
                        exit;
                }
        };
        exit;
}


failure_route[missed_call] {

                #if (use_next_gw(, , $var(carrier_attrs))) {
                if (use_next_gw(, $avp(gw_id),$avp(carrier_id))) {
                      xlog("MissedCall--Next Gateway: From=$fu, To=$tu,RU=$ru, 
CI=$ci IP=$si\n");
                      xlog("Carrier attributes of current gateway: $avp(gw_id). 
carrier: $avp(carrier_id)\n");

                      t_on_failure("missed_call");
                      route(relay);
                      exit;
                }
                else {
                        send_reply(503, "Service not available, no more gws");
                        exit;
                }




Thank you.





_______________________________________________
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

Reply via email to