Hello,

On 10/30/12 10:51 AM, Grant Bagdasarian wrote:

Hello Community,

 

I’ve recently started to use the Dialog module to manage the amount of incoming calls from our SIP provider allowed to pass through by using profiles_with_values and setting the size of these profiles to a certain amount.

Most of the time this works as it should, but sometimes the ‘slots’ available for a profile aren’t cleared even though a dialog has finished. This seems to happen when an high amount of regular traffic is hitting kamailio.

 

Has anyone else experienced this? Are there perhaps any other ways to control the slots available for certain incoming SIP traffic?

 

Below parts of my configuration file. Perhaps I’m doing something wrong which causes this to happen.

In my route[WITHINDLG] -> loose_route -> is_method(“BYE”) I’m not calling dlg_manage(), could this be the problem?

is the dlg_manage() executed or not for BYE? You say no above, but the example has it. Because you have dlg_match_mode=2, you must call dlg_manage() for BYE explicitly.

Cheers,
Daniel

 

Other comments are welcome too, as I’m fairly new to Kamailio.

 

modparam("dialog", "enable_stats", 1)

modparam("dialog", "dlg_flag", 4)

modparam("dialog", "hash_size", 4096)

modparam("dialog", "profiles_with_value", "318005004");

modparam("dialog", "default_timeout", 43200)

modparam("dialog", "dlg_match_mode",2)

modparam("dialog", "detect_spirals", 1)

 

request_route {

 

        # per request initial checks

        route(REQINIT);

 

        # handle requests within SIP dialogs

        route(WITHINDLG);

 

        ### only initial requests (no To tag)

 

        # CANCEL processing

        if (is_method("CANCEL"))

        {

                if (t_check_trans())

                        t_relay();

                exit;

        }

 

        t_check_trans();

 

        # record routing for dialog forming requests (in case they are routed)

        # - remove preloaded route headers

        remove_hf("Route");

 

       if (is_method("INVITE")) {

              xlog("L_INFO", "Incoming request for $rU from $fU");

              if ($rU == "318005004") {

                     route(DIALOG);

              }

        }

 

        # handle registrations

        route(REGISTRAR);

 

        if ($rU==$null)

        {

                # request with no Username in RURI

                sl_send_reply("484","Address Incomplete");

                exit;

        }

 

        # dispatch destinations

        route(DISPATCH);

 

        route(RELAY);

}

 

route[DIALOG] {

       dlg_manage();

       record_route();

       $var(SIZE) = 0;

 

       sql_query("vf", "exec dbo.SelectAvailableSlots '00$rU'", "ra");

       $avp(s:limit) = $dbr(ra=>[0,7]);

       xlog("L_INFO", "Maximum simultaneous calls is configured at $avp(s:limit) ....");

       sql_result_free("ra");

      

       if ($rU == "318005004") {

              get_profile_size("318005004", "$rU", "$var(SIZE)");

       }

 

 

       xlog("L_INFO", "There are currently $var(SIZE) calls for $rU, excluding the current call");

       if($var(SIZE) >= $avp(s:limit)) {

              xlog("L_INFO", "Simultaneous calls limit of $avp(s:limit) reached for $rU: $var(SIZE)\n");

              sl_send_reply("603", "Simultaneous calls limit reached");

              exit;

       }

 

       if ($rU == "318005004") {

              set_dlg_profile("318005004", "$rU");

       }

 

 

       if ($rU == "318005004") {

              if(get_profile_size("318005004", "$var(SIZE)")) {

                     xlog("L_INFO", "There are currently $var(SIZE) calls for $rU, including the current call");

              }

       }

}

 

route[WITHINDLG] {

        if (has_totag()) {

                # sequential request withing a dialog should

                # take the path determined by record-routing

                if (loose_route()) {

                     #Used for call transfer

                     if($fU == "318005004") {

                        if (is_method("UPDATE")) {

                            sl_send_reply("405","Method not allowed");

                            xlog("L_INFO", "Dropping UPDATE message...\n");

                            exit;

                        }

                        if (is_method("INVITE")) {

                            record_route();

                        }

                        if (is_method("BYE")) {

                            dlg_manage();

                        }

                     }

                        if (is_method("BYE")) {

                                setflag(1); # do accounting ...

                                setflag(3); # ... even if the transaction fails

                        }

                        route(RELAY);

                } else {

                        if (is_method("SUBSCRIBE") && uri == myself) {

                                # in-dialog subscribe requests

                                route(PRESENCE);

                                exit;

                        }

                        if ( is_method("ACK") ) {

                                if ( t_check_trans() ) {

                                        # non loose-route, but stateful ACK;

                                        # must be 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;

        }

}

 

 

Regards,

 

Grant

 



_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla - http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Kamailio Advanced Training, Berlin, Nov 5-8, 2012 - http://asipto.com/u/kat
Kamailio Advanced Training, Miami, USA, Nov 12-14, 2012 - http://asipto.com/u/katu