[OpenSIPS-Users] Load_Balancer module - disabling GW from routing script

Alejandro Recarey alexrecarey at gmail.com
Wed Sep 22 12:11:00 CEST 2010


Thank you Bogdan, makes a lot of sense!

On Wed, Sep 22, 2010 at 11:43 AM, Bogdan-Andrei Iancu
<bogdan at voice-system.ro> wrote:
> Hi Alejandro,
>
> You need to extend your test to catch only "locally generated timeouts"
> and to skip "received timeouts". For this use the t_local_replied()
> functions :
>          http://www.opensips.org/html/docs/modules/1.6.x/tm.html#id272062
>
> And make the condition like:
>
>
> if (t_check_status("(408)") && t_local_replied("all")) {
>
>
> Regards,
> Bogdan
>
> Alejandro Recarey wrote:
>> Hi all,
>>
>> I am currently trying to enable GW disabling from inside the routing
>> script with the load balancer.
>>
>> I managed to get it working reading the module documentation, but now
>> I have a problem. I want the gateway to be disabled only if it is
>> unreachable, that is, if it does not answer at all to the SIP INVITE
>> being sent, but the Asterisk Gatways are being disabled all the time,
>> every 5 - 10 minutes. The part of routing script that takes care of
>> the load balancing is:
>>
>>
>> . . . (ommited) . . .
>>
>> # ---- Outbound to Load Balancer---- #
>>     if(uri=~"^sip:5378[0-9]*+@"){
>>     route(7);
>> }
>>
>>
>> # ---- Load Balancer ---- #
>> route[7] {
>>     if (load_balance("2","pstn","1")) {
>>         if (is_method("INVITE")) {
>>                 t_on_branch("2");
>>                 t_on_reply("2");
>>                 t_on_failure("2"); #custom failure route for LB
>>         }
>>
>>         if (!t_relay()) {
>>                 sl_reply_error();
>>         };
>>         exit;
>>
>>     }
>>     else{
>>         sl_send_reply("503","Service full");
>>         exit;
>>     }
>> }
>>
>>
>> # Failure route for Load Balancer
>> failure_route[2] {
>>         if (t_was_cancelled()) {
>>                 exit;
>>         }
>>
>>         # If status is 408 - Timeout, disable route
>>         if (t_check_status("(408)")) {
>>                 lb_disable();
>>
>>                 # Try to load balance once again
>>                 if ( load_balance("2","pstn","1") ) {
>>                         t_on_failure("1");
>>                         t_relay();
>>                 } else {
>>                         t_reply("503","Service Unavailable");
>>                 }
>>         }
>> }
>>
>> If I execute opensipctl fifo lb_list:
>>
>> Destination:: sip:x.x.x.x id=5 group=2 enabled=yes auto-re=on
>>         Resource:: pstn max=90 load=13
>> Destination:: sip:x.x.x.x id=6 group=2 enabled=yes auto-re=on
>>         Resource:: pstn max=60 load=9
>> Destination:: sip:x.x.x.x id=7 group=2 enabled=yes auto-re=on
>>         Resource:: pstn max=60 load=9
>>
>>
>> As you can see, I only disable the GW if I receive a SIP 408 message.
>> I thought this message would only be generated if the SIP INVITE timed
>> out, but it seems Asterisk is sending a 408 message for normal call
>> reasons (maybe when the dialed party does not pick up and the dial
>> times out??)
>>
>> This is a huge problem because my termination GW are being disabled
>> all of the time, and randomly. Since my OpenSIPS server is in
>> production and I cannot reload config until tonight I have setup a
>> cronjob that enables the gateways every minute, but it's hardly an
>> optimal solution ;)
>>
>> Does anybody have experience with the setup described? (OpenSIPS
>> Load_Balancer + Asterisk with in script disable of bad GW's?). Any
>> pointers would be appreciated, thanks!
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
>>
>
>
> --
> Bogdan-Andrei Iancu
> OpenSIPS Bootcamp
> 15 - 19 November 2010, Edison, New Jersey, USA
> www.voice-system.ro
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>



More information about the Users mailing list