limiting the number of gateways tried in lcr module

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

limiting the number of gateways tried in lcr module

Andrew Pogrebennyk-3
Hello,

How do I limit the number of gateways tried in lcr module? Say, try only
2 (or 3, 4) gateways even if there are 5 matching gateways in the database?

I can't do that by using the script variable because failure route is
reenterable and variable doesn't keep its value between entering. I also
couldn't achieve that by using AVPs. Any ideas?

--
Sincerely,
Andrew Pogrebennyk

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: limiting the number of gateways tried in lcr module

Brett Nemeroff
You should be able to track this with avps. What version are you running? I know that in at least the newer versions of opensips, this is definitely supported:
"The AVPS will be visible in all routes where any message (reply or request) of the transaction will be processed - branch_route , failure_route, onreply_route (for this last route you need to enable the TM parameter onreply_avp_mode)."


On Thu, May 28, 2009 at 6:51 AM, Andrew Pogrebennyk <[hidden email]> wrote:
Hello,

How do I limit the number of gateways tried in lcr module? Say, try only
2 (or 3, 4) gateways even if there are 5 matching gateways in the database?

I can't do that by using the script variable because failure route is
reenterable and variable doesn't keep its value between entering. I also
couldn't achieve that by using AVPs. Any ideas?

--
Sincerely,
Andrew Pogrebennyk

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: limiting the number of gateways tried in lcr module

Andrew Pogrebennyk-3
Brett Nemeroff wrote:
> You should be able to track this with avps. What version are you running? I
> know that in at least the newer versions of opensips, this
> is definitely supported:http://www.opensips.org/Resources/DocsCoreVar14
> "The AVPS will be visible in all routes where any message (reply or request)
> of the transaction will be processed - branch_route , failure_route,
> onreply_route (for this last route you need to enable the TM parameter *
> onreply_avp_mode*)."

Thanks. I don't have the config or the logs at hand at this moment but I
tried something like this yesterday:

failure_route[1] {
        if (!isflagset(31)) {
                $avp(i:500) = 1; # Initialize counter of failed attempts
                setflag(31);
        } else {
                $avp(i:500) = $avp(i:500) + 1; # OR:
                # avp_op("$avp(i:500)", "add/1");
        }
        if ($avp(i:500) > 2) {
                t_reply("503", "Couldn't complete the call");
                exit;
        }
        if (next_gw()) {
                t_on_failure("1");
                t_relay();
        } else {
                t_reply("503", "No gateways");
                exit;
        };
}

As a result of incrementing AVP variable, no matter which way, the
OpenSIPS sends out some junk and then crashes... I'm using 1.4.4.

--
Sincerely,
Andrew Pogrebennyk
PortaOne, Inc., QA Engineer
[hidden email]
Tel: +1-866-SIP VOIP (+1 866 747 8647) ext. 7133

Meet us on June 1-3 at ITW, Booth 802
Marriott Wardman Park Hotel, Washington, DC
http://www.internationaltelecomsweek.com/

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: limiting the number of gateways tried in lcr module

Brett Nemeroff
I don't entirely remember the way the arming of the flags works and how they persist across failure_routes. Maybe someone can comment on that?

Instead of using flags, call:
               $avp(i:500) = 1; # Initialize counter of failed attempts

from your main route block, before failure route is called. 

Let us know how that works for you..
-Brett

On Thu, May 28, 2009 at 7:34 AM, Andrew Pogrebennyk <[hidden email]> wrote:
Brett Nemeroff wrote:
You should be able to track this with avps. What version are you running? I
know that in at least the newer versions of opensips, this
is definitely supported:http://www.opensips.org/Resources/DocsCoreVar14
"The AVPS will be visible in all routes where any message (reply or request)
of the transaction will be processed - branch_route , failure_route,
onreply_route (for this last route you need to enable the TM parameter *
onreply_avp_mode*)."

Thanks. I don't have the config or the logs at hand at this moment but I tried something like this yesterday:

failure_route[1] {
       if (!isflagset(31)) {
               $avp(i:500) = 1; # Initialize counter of failed attempts
               setflag(31);
       } else {
               $avp(i:500) = $avp(i:500) + 1; # OR:
               # avp_op("$avp(i:500)", "add/1");
       }
       if ($avp(i:500) > 2) {
               t_reply("503", "Couldn't complete the call");
               exit;
       }
       if (next_gw()) {
               t_on_failure("1");
               t_relay();
       } else {
               t_reply("503", "No gateways");
               exit;
       };
}

As a result of incrementing AVP variable, no matter which way, the OpenSIPS sends out some junk and then crashes... I'm using 1.4.4.

--
Sincerely,
Andrew Pogrebennyk
PortaOne, Inc., QA Engineer
[hidden email]
Tel: +1-866-SIP VOIP (+1 866 747 8647) ext. 7133

Meet us on June 1-3 at ITW, Booth 802
Marriott Wardman Park Hotel, Washington, DC
http://www.internationaltelecomsweek.com/


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: limiting the number of gateways tried in lcr module

Andrew Pogrebennyk-3
Thanks for your input, Brett. I tried to initialize the counter from the
main route block, but it didn't work - somehow I ended up with rURI in
$avp(i:500). Then I rewrote the failure_route exactly like in the
example I have provided earlier - and it worked like a magic. Previously
I've had the same pieces of logic, just written in a different way, so I
don't know what was the problem with it. Anyway I'm happy with the way
it works now. In case anyone wonders, here is my working failure_route:

failure_route[1] {
         # -----------------------------------------------------------------
         # Failover to next gateway if any
         # -----------------------------------------------------------------
        if (!isflagset(31)) {
                $avp(i:500) = 1; # Initialize counter of failed attempts
                setflag(31);
        } else {
                $avp(i:500) = $avp(i:500) + 1; # OR:
                # avp_op("$avp(i:500)", "add/1");
        }
        xlog("L_INFO", "----- Made $avp(i:500) failed attempts\n");
        if (t_check_status("403")) {
                xlog("L_INFO", "----- Got 403 response; no more gateways
will be tried\n");
                t_reply("403", "Forbidden");
                exit;
        }
        if ($avp(i:500) >= 2) { # limit on the search depth is set here
                xlog("L_INFO", "----- Didn't get positive response from
two gateways; giving up\n");
                t_reply("503", "Couldn't complete the call");
                exit;
        }
        if (next_gw()) {
                t_on_failure("1");
                t_relay();
        } else {
                t_reply("503", "No gateways");
                exit;
        };
}

Brett Nemeroff wrote:

> I don't entirely remember the way the arming of the flags works and how
> they persist across failure_routes. Maybe someone can comment on that?
>
> Instead of using flags, call:
>                $avp(i:500) = 1; # Initialize counter of failed attempts
>
> from your main route block, before failure route is called.
>
> Let us know how that works for you..
> -Brett

--
Sincerely,
Andrew Pogrebennyk

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: limiting the number of gateways tried in lcr module

Bogdan-Andrei Iancu
Hi Andrew,

You can simply and get rid of the flag by simply testing if the AVP is
present or not:

failure_route[1] {
         # -----------------------------------------------------------------
         # Failover to next gateway if any
         # -----------------------------------------------------------------
        if ( !is_avp_set("$avp(i:500)") ) {
                $avp(i:500) = 1; # Initialize counter of failed attempts
        } else {
                $avp(i:500) = $avp(i:500) + 1; # OR:
                # avp_op("$avp(i:500)", "add/1");
        }
        xlog("L_INFO", "----- Made $avp(i:500) failed attempts\n");



Regards,
Bogdan

Andrew Pogrebennyk wrote:

> Thanks for your input, Brett. I tried to initialize the counter from the
> main route block, but it didn't work - somehow I ended up with rURI in
> $avp(i:500). Then I rewrote the failure_route exactly like in the
> example I have provided earlier - and it worked like a magic. Previously
> I've had the same pieces of logic, just written in a different way, so I
> don't know what was the problem with it. Anyway I'm happy with the way
> it works now. In case anyone wonders, here is my working failure_route:
>
> failure_route[1] {
>          # -----------------------------------------------------------------
>          # Failover to next gateway if any
>          # -----------------------------------------------------------------
>         if (!isflagset(31)) {
>                 $avp(i:500) = 1; # Initialize counter of failed attempts
>                 setflag(31);
>         } else {
>                 $avp(i:500) = $avp(i:500) + 1; # OR:
>                 # avp_op("$avp(i:500)", "add/1");
>         }
>         xlog("L_INFO", "----- Made $avp(i:500) failed attempts\n");
>         if (t_check_status("403")) {
>                 xlog("L_INFO", "----- Got 403 response; no more gateways
> will be tried\n");
>                 t_reply("403", "Forbidden");
>                 exit;
>         }
>         if ($avp(i:500) >= 2) { # limit on the search depth is set here
>                 xlog("L_INFO", "----- Didn't get positive response from
> two gateways; giving up\n");
>                 t_reply("503", "Couldn't complete the call");
>                 exit;
>         }
>         if (next_gw()) {
>                 t_on_failure("1");
>                 t_relay();
>         } else {
>                 t_reply("503", "No gateways");
>                 exit;
>         };
> }
>
> Brett Nemeroff wrote:
>  
>> I don't entirely remember the way the arming of the flags works and how
>> they persist across failure_routes. Maybe someone can comment on that?
>>
>> Instead of using flags, call:
>>                $avp(i:500) = 1; # Initialize counter of failed attempts
>>
>> from your main route block, before failure route is called.
>>
>> Let us know how that works for you..
>> -Brett
>>    
>
>  


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users