Re: [OpenSIPS-Users] mid_registrar load balance

2020-11-13 Thread David Villasmil
You should be able to use the dispatcher module just before relaying. Have
you tried that?

On Fri, 13 Nov 2020 at 13:09, Andy Kama  wrote:

> Hi Guys
>
> is it possible to load balance with mid_registrar?
> perhaps setting multiple $ru in this part
>
>if (is_method("REGISTER")) {
> mid_registrar_save("location");
> switch ($retcode) {
> case 1:
> xlog("forwarding REGISTER to main registrar ($$ci=$ci)\n");
> $ru = "sip:1.2.3.4:5060";
> t_relay();
> break;
> case 2:
> xlog("absorbing REGISTER! ($$ci=$ci)\n");
> break;
> default:
> xlog("failed to save registration! ($$ci=$ci)\n");
> }
>
> exit;
> }
> ___
> Users mailing list
> Users@lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
-- 
Regards,

David Villasmil
email: david.villasmil.w...@gmail.com
phone: +34669448337
___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


Re: [OpenSIPS-Users] mid_registrar load balance

2020-11-13 Thread Alain Bieuzent
Hi Andy,

 

I’m doing it manually :

 

   if (is_method("REGISTER"))

    {

    fix_nated_contact();

    mid_registrar_save("location");

    switch ($retcode)

    {

    case 1:

    if (!cache_fetch("local", "$ci", $avp(IP)))

    {

    avp_db_query("SELECT destination FROM 
lbsip_sbc_did_3_0.dispatcher where setid = 1 and state = 0 ORDER BY RAND() 
LIMIT 1", "$avp(IP)");

    if ($rc < 0)

    {

    xlog("L_WARN", 
"$ci|REGISTER|Mysql query failed or no result, droping call with a 500");

    sl_send_reply(500, "internal 
Server error");

    exit;

    }

    cache_store("local", "$ci", "$avp(IP)", 
3600);

    }

    else

    {

    $var(IP) = $(avp(IP){uri.host});

    if (!ds_is_in_list("$var(IP)",5060,1, 
,1))

    {

    xlog("L_INFO", 
"$ci|REGISTER|Destination in cache is unreachable forwarding query to another 
astsipac)");

    avp_db_query("SELECT 
destination FROM lbsip_sbc_did_3_0.dispatcher where setid = 1 and state = 0 
ORDER BY RAND() LIMIT 1", "$avp(IP)");

 

    if ($rc < 0)

    {

    xlog("L_WARN", 
"$ci|REGISTER|Mysql query failed or no result, droping call with a 500");

    sl_send_reply(500, 
"internal Server error");

    exit;

    }

    cache_store("local", "$ci", "$avp(IP)", 
3600);

    xlog("L_INFO", "$ci|REGISTER|new 
destination is $avp(IP)");

    }

    }

    $ru = $avp(IP);

    xlog("L_INFO", "$ci|forwarding REGISTER from: 
$ct - $tU:$si to: $ru");

    cache_store("local", "$ci", "$avp(IP)", 3600);

    t_relay();

    break;

 

    case 2:

    xlog("L_INFO", "absorbing REGISTER for $tU ");

            break;

 

    default:

    xlog("L_INFO", "failed to save registration for 
$tU");

    }

 

De : Users  au nom de Andy Kama 

Répondre à : OpenSIPS users mailling list 
Date : vendredi 13 novembre 2020 à 14:12
À : 
Objet : [OpenSIPS-Users] mid_registrar load balance

 

Hi Guys

 

is it possible to load balance with mid_registrar?

perhaps setting multiple $ru in this part

 

   if (is_method("REGISTER")) {
mid_registrar_save("location");
switch ($retcode) {
case 1:
xlog("forwarding REGISTER to main registrar ($$ci=$ci)\n");
$ru = "sip:1.2.3.4:5060";
t_relay();
break;
case 2:
xlog("absorbing REGISTER! ($$ci=$ci)\n");
break;
default:
xlog("failed to save registration! ($$ci=$ci)\n");
}

exit;
}

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

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


[OpenSIPS-Users] mid_registrar load balance

2020-11-13 Thread Andy Kama
Hi Guys

is it possible to load balance with mid_registrar?
perhaps setting multiple $ru in this part

   if (is_method("REGISTER")) {
mid_registrar_save("location");
switch ($retcode) {
case 1:
xlog("forwarding REGISTER to main registrar ($$ci=$ci)\n");
$ru = "sip:1.2.3.4:5060";
t_relay();
break;
case 2:
xlog("absorbing REGISTER! ($$ci=$ci)\n");
break;
default:
xlog("failed to save registration! ($$ci=$ci)\n");
}

exit;
}
___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users