<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style></head><body lang=FR link=blue vlink=purple style='word-wrap:break-word'><div class=WordSection1><p class=MsoNormal><span style='mso-fareast-language:EN-US'>Hi Andy,<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>I’m doing it manually :<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>       if (is_method("REGISTER"))<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>        {<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                fix_nated_contact();<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                mid_registrar_save("location");<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                switch ($retcode)<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                {<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                        case 1:<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                if (!cache_fetch("local", "$ci", $avp(IP)))<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                {<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                        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)");<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                        if ($rc < 0)<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                        {<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                                xlog("L_WARN", "$ci|REGISTER|Mysql query failed or no result, droping call with a 500");<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                                sl_send_reply(500, "internal Server error");<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                                exit;<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                        }<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                        cache_store("local", "$ci", "$avp(IP)", 3600);<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                }<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                else<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                {<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                        $var(IP) = $(avp(IP){uri.host});<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                        if (!ds_is_in_list("$var(IP)",5060,1, ,1))<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                        {<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                                xlog("L_INFO", "$ci|REGISTER|Destination in cache is unreachable forwarding query to another astsipac)");<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                                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)");<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                                if ($rc < 0)<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                                {<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                                        xlog("L_WARN", "$ci|REGISTER|Mysql query failed or no result, droping call with a 500");<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                                        sl_send_reply(500, "internal Server error");<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                                        exit;<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                                }<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                        cache_store("local", "$ci", "$avp(IP)", 3600);<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                        xlog("L_INFO", "$ci|REGISTER|new destination is $avp(IP)");<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                        }<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                }<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                $ru = $avp(IP);<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                xlog("L_INFO", "$ci|forwarding REGISTER from: $ct - $tU:$si to: $ru");<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                cache_store("local", "$ci", "$avp(IP)", 3600);<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                t_relay();<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                break;<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                        case 2:<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                xlog("L_INFO", "absorbing REGISTER for $tU ");<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                break;<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                        default:<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                                xlog("L_INFO", "failed to save registration for $tU");<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>                }<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span style='font-size:12.0pt;color:black'>De : </span></b><span style='font-size:12.0pt;color:black'>Users <users-bounces@lists.opensips.org> au nom de Andy Kama <andyvoicetek@gmail.com><br><b>Répondre à : </b>OpenSIPS users mailling list <users@lists.opensips.org><br><b>Date : </b>vendredi 13 novembre 2020 à 14:12<br><b>À : </b><users@lists.opensips.org><br><b>Objet : </b>[OpenSIPS-Users] mid_registrar load balance<o:p></o:p></span></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Hi Guys<o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>is it possible to load balance with mid_registrar?<o:p></o:p></p></div><div><p class=MsoNormal>perhaps setting multiple $ru in this part<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>               if (is_method("REGISTER")) {<br>        mid_registrar_save("location");<br>        switch ($retcode) {<br>        case 1:<br>            xlog("forwarding REGISTER to main registrar ($$ci=$ci)\n");<br>            $ru = "sip:<a href="http://1.2.3.4:5060">1.2.3.4:5060</a>";<br>            t_relay();<br>            break;<br>        case 2:<br>            xlog("absorbing REGISTER! ($$ci=$ci)\n");<br>            break;<br>        default:<br>            xlog("failed to save registration! ($$ci=$ci)\n");<br>        }<br><br>        exit;<br>    }<o:p></o:p></p></div></div><p class=MsoNormal>_______________________________________________ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users <o:p></o:p></p></div></body></html>