[OpenSIPS-Users] mid_registrar load balance

Alain Bieuzent alain.bieuzent at free.fr
Fri Nov 13 13:19:30 EST 2020


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 <users-bounces at lists.opensips.org> au nom de Andy Kama <andyvoicetek at gmail.com>
Répondre à : OpenSIPS users mailling list <users at lists.opensips.org>
Date : vendredi 13 novembre 2020 à 14:12
À : <users at lists.opensips.org>
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 at lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20201113/8c08697c/attachment-0001.html>


More information about the Users mailing list