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