[OpenSIPS-Users] Load balancer ORed resource types

Bogdan-Andrei Iancu bogdan at voice-system.ro
Tue Dec 22 09:18:21 CET 2009


Hi Taner,

So, you have a call and you first try to do LB in group 8002 (in 
route[3]) and if failed, in group 8003.....which does not work properly 
as you said...

Can you run in debug=6 and post here the output related to the INVITE 
processing ?

Regards,
Bogdan

Taner Sener wrote:
> Hi Bogdan,
>
> In my tests when all resources from group id 1 (with higher priority) 
> are busy (or fail to accept call with some error) I'm calling 
> load_balance for group id 2. Although there is available destinations 
> on this group, return code from load_balance call is < 0. So this is 
> the point where I'm stuck. 
>
> Any help appreciated.
>
> Here's my configuration.
>
> load_balancer table
> -------------------------------
> +----+----------+---------------------+-----------+------------+-------------+
> | id | group_id | dst_uri             | resources | probe_mode | 
> description |
> +----+----------+---------------------+-----------+------------+-------------+
> | 95 |     8002 | sip:ar at 10.10.5.23 <mailto:sip%3Aar at 10.10.5.23>   | 
> sip=1     |          2 |             |
> | 19 |     8002 | sip:ar at 10.10.5.44 <mailto:sip%3Aar at 10.10.5.44>   | 
> sip=1     |          2 |             |
> | 20 |     8003 | sip:ar at 10.210.54.86 <mailto:sip%3Aar at 10.210.54.86> | 
> sip=1     |          2 |             |
> | 96 |     8002 | sip:ar at 10.10.5.13 <mailto:sip%3Aar at 10.10.5.13>   | 
> sip=1     |          2 |             |
> | 97 |     8002 | sip:ar at 10.10.5.10 <mailto:sip%3Aar at 10.10.5.10>   | 
> sip=1     |          2 |             |
> | 98 |     8002 | sip:ar at 10.10.6.50 <mailto:sip%3Aar at 10.10.6.50>   | 
> sip=1     |          2 |             |
> ...
>
> opensips.cfg
> ----------------------
> ####### Global Parameters #########
>
> debug=3
> log_stderror=no
> log_facility=LOG_LOCAL6
>
> fork=yes
> children=4
>
> /* uncomment the next line to disable TCP (default on) */
> disable_tcp=yes
>
> port=5060
>
> ####### Modules Section ########
>
> #set module path
> mpath="//lib/opensips/modules/"
>
> /* uncomment next line for MySQL DB support */
> loadmodule "db_mysql.so"
> loadmodule "signaling.so"
> loadmodule "sl.so"
> loadmodule "tm.so"
> loadmodule "rr.so"
> loadmodule "maxfwd.so"
> loadmodule "usrloc.so"
> loadmodule "registrar.so"
> loadmodule "textops.so"
> loadmodule "mi_fifo.so"
> loadmodule "uri.so"
> loadmodule "xlog.so"
> loadmodule "acc.so"
>
> /* uncomment next lines for MySQL based authentication support 
>    NOTE: a DB (like db_mysql) module must be also loaded */
> loadmodule "auth.so"
> loadmodule "auth_db.so"
>
> # needed for load balancer module
> loadmodule "dialog.so"
> loadmodule "load_balancer.so"
>
> # ----------------- setting module-specific parameters ---------------
>
>
> # ----- mi_fifo params -----
> modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
>
>
> # ----- rr params -----
> modparam("rr", "enable_double_rr", 1)
> modparam("rr", "append_fromtag", 1)
>
>
> # ----- usrloc params -----
> modparam("usrloc", "db_mode",   0)
>
>
> # ----- uri params -----
> modparam("uri", "use_uri_table", 0)
>
>
> # ----- acc params -----
> /* what sepcial events should be accounted ? */
> modparam("acc", "early_media", 1)
> modparam("acc", "report_ack", 0)
> modparam("acc", "report_cancels", 0)
>
> /* by default ww do not adjust the direct of the sequential requests.
>    if you enable this parameter, be sure the enable "append_fromtag"
>    in "rr" module */
> modparam("acc", "detect_direction", 0)
>
> /* account triggers (flags) */
> modparam("acc", "failed_transaction_flag", 3)
>
> /* uncomment the following lines to enable DB accounting also */
> modparam("acc", "db_flag", 1)
> modparam("acc", "db_missed_flag", 2)
>
>
> # ----- auth_db params -----
> /* uncomment the following lines if you want to enable the DB based
>    authentication */
> modparam("auth_db", "calculate_ha1", yes)
> modparam("auth_db", "password_column", "password")
>
>
> # ----- tm params -----
> modparam("tm", "fr_timer", 5)
> modparam("tm", "fr_inv_timer", 5)
>
>
> # ----- load balancer params -----
> modparam("load_balancer", "db_url", 
> "mysql://opensips:opensipsrw@localhost/opensips16")
> modparam("load_balancer", "db_table", "load_balancer")
> modparam("load_balancer", "probing_interval", 20)
> modparam("load_balancer", "probing_method", "OPTIONS")
> modparam("load_balancer", "probing_from", "sip:proxy at 192.168.187.121 
> <mailto:sip%3Aproxy at 192.168.187.121>")
>
> ####### Routing Logic ########
>
>
> # main request routing logic
> route{
> if (!mf_process_maxfwd_header("10")) {
> sl_send_reply("483","Too Many Hops");
> exit;
> }
>
> if (has_totag()) {
> # sequential request withing a dialog should
> # take the path determined by record-routing
> if (loose_route()) {
> if (is_method("BYE")) {
> setflag(1); # do accounting ...
> setflag(3); # ... even if the transaction fails
> } else if (is_method("INVITE")) {
> # even if in most of the cases is useless, do RR for
> # re-INVITEs alos, as some buggy clients do change route set
> # during the dialog.
> record_route();
> }
> # route it out to whatever destination was set by loose_route()
> # in $du (destination URI).
> route(1);
> } else {
> if ( is_method("ACK") ) {
> if ( t_check_trans() ) {
> # non loose-route, but stateful ACK; must be an ACK after 
> # a 487 or e.g. 404 from upstream server
> t_relay();
> exit;
> } else {
> # ACK without matching transaction ->
> # ignore and discard
> exit;
> }
> }
> sl_send_reply("404","Not here");
> }
> exit;
> }
>
> #initial requests
>
> # CANCEL processing
> if (is_method("CANCEL"))
> {
> if (t_check_trans())
> t_relay();
> exit;
> }
>
> t_check_trans();
>
> # preloaded route checking
> if (loose_route()) {
> xlog("L_ERR",
> "Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");
> if (!is_method("ACK"))
> sl_send_reply("403","Preload Route denied");
> exit;
> }
>
> # record routing
> if (!is_method("REGISTER|MESSAGE"))
> record_route();
>
> # account only INVITEs
> if (is_method("INVITE")) {
> setflag(1); # do accounting
> }
> if (is_method("PUBLISH"))
> {
> sl_send_reply("503", "Service Unavailable");
> exit;
> }
> if ($rU==NULL) {
> # request with no Username in RURI
> sl_send_reply("484","Address Incomplete");
> exit;
> }
>
> # when routing via usrloc, log the missed calls also
> setflag(2);
>
> route(3);
> }
>
> route[1] {
> # for INVITEs enable some additional helper routes
> if (is_method("INVITE")) {
> t_on_branch("2");
> t_on_reply("2");
> t_on_failure("1");
> }
>
> if (!t_relay()) {
> sl_reply_error();
> };
> exit;
> }
>
>
> route[3] {
>         if (is_method("INVITE")) {
>             load_balance("8002", "sip");
>             if ($retcode < 0) {
>              xlog("L_INFO", "load_balancer: Insufficient resource to 
> balance request from $fu to $tu . Re-balancing to route 4!\n");
> route(4);
>             } 
>         }
> t_on_failure("2");
>
> # send request
> if (!t_relay()) {
> sl_reply_error();
> }
> exit;
> }
>
> route[4] {
>         if (is_method("INVITE")) {
>             load_balance("8003", "sip");
>             if ($retcode < 0) {
>              xlog("L_INFO", "load_balancer: Insufficient resource to 
> balance request from $fu to $tu . Sending error!\n");
>                 sl_send_reply("500", "Service full");
>                 exit;
>             } 
>         }
> # send request
> if (!t_relay()) {
> sl_reply_error();
> }
> exit;
> }
>
>
> branch_route[2] {
> xlog("new branch at $ru\n");
> }
>
>
> onreply_route[2] {
> xlog("incoming reply\n");
> }
>
> de
>
> failure_route[1] {
> if (t_was_cancelled()) {
> exit;
> }
>
> # uncomment the following lines if you want to block client 
> # redirect based on 3xx replies.
> ##if (t_check_status("3[0-9][0-9]")) {
> ##t_reply("404","Not found");
> ## exit;
> ##}
>
> # uncomment the following lines if you want to redirect the failed 
> # calls to a different new destination
> ##if (t_check_status("486|408")) {
> ## sethostport("192.168.2.100:5060 <http://192.168.2.100:5060>");
> ## # do not set the missed call flag again
> ## t_relay();
> ##}
> }
>
>
> failure_route[2] {
>         if (t_was_cancelled()) {
>                 exit;
>         }
>         
>         if (t_check_status("486|408|603")) {
>             xlog("L_INFO", "load_balancer: Request from $fu to $tu 
> failed. Re-balancing to 8002!\n");
>             lb_disable();
>             load_balance("8002", "sip");
>
>             if ($retcode < 0) {
>              xlog("L_INFO", "load_balancer: Insufficient resource to 
> balance request from $fu to $tu . Re-balancing to route 4!\n");
> route(4);
>             }
>    t_on_failure("2");
>             t_relay();
> }
> } 
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>   


-- 
Bogdan-Andrei Iancu
www.voice-system.ro




More information about the Users mailing list