Hi Andrzej,

are you trying to setup cnxcc to check both credit and maximum simultaneous calls?

Regards,



On Sat, Apr 26, 2014 at 9:26 AM, Andrzej Ciupek <andrzej.ciupek@hotmail.com> wrote:
Hello

I’am using default config with options from an example. It looks like event route isn’t execuded after hangup.

Apr 26 16:26:14 kamailio /usr/local/sbin/kamailio[4611]: INFO: <script>: 1000 has 1 call(s)
Apr 26 16:26:15 kamailio /usr/local/sbin/kamailio[4611]: INFO: <script>: 1000 has 1 call(s)
Apr 26 16:26:16 kamailio /usr/local/sbin/kamailio[4611]: INFO: <script>: 1000 has 1 call(s)
Apr 26 16:26:17 kamailio /usr/local/sbin/kamailio[4611]: INFO: <script>: 1000 has 1 call(s)
Apr 26 16:26:18 kamailio /usr/local/sbin/kamailio[4611]: INFO: <script>: 1000 has 1 call(s)
Apr 26 16:26:19 kamailio /usr/local/sbin/kamailio[4611]: INFO: <script>: 1000 has 1 call(s)
Apr 26 16:26:20 kamailio /usr/local/sbin/kamailio[4611]: INFO: <script>: 1000 has 1 call(s)
Apr 26 16:26:20 kamailio /usr/local/sbin/kamailio[4604]: INFO: <script>: Setting up money based credit control
Apr 26 16:26:20 kamailio /usr/local/sbin/kamailio[4604]: INFO: <script>: Setting up channel based credit control
Apr 26 16:26:20 kamailio /usr/local/sbin/kamailio[4604]: INFO: <script>: CNXCC ROUTE: 1000 has 2 call(s)

kamailio.cfg
# ----- prepaid call controll -----

#!define DLG_FLAG 28
#!define CC_FLAG 29

loadmodule "dialog.so"

modparam("dialog", "hash_size", 2048)
modparam("dialog", "default_timeout", 3600)
modparam("dialog", "db_mode", 0)
modparam("dialog", "dlg_flag", DLG_FLAG)

modparam("rtimer", "timer", "name=ta;interval=1;mode=1;")
modparam("rtimer", "exec", "timer=ta;route=SHOW_CHANNEL_COUNT")

loadmodule "cnxcc.so"

modparam("cnxcc", "dlg_flag", CC_FLAG)
modparam("cnxcc", "credit_check_period", 1) #check every 1 second

route {
 if (!allow_source_address("2") and !allow_source_address("1")){
        route(CNXCC);
        route(PSTN);
        }
}

route[CNXCC]
{

        $var(client)            = "1000";

        xlog("L_INFO", "Setting up money based credit control");

        $var(credit)            = "10"; # 10$ of credit
        $var(cost_per_sec)      = "1";  # 1$ per sec
        $var(i_pulse)           = "1";  # 1$ to establish the call
        $var(f_pulse)           = "1";  # 1$ per second

        # if only one call is established, that call should last 9 seconds.

        if (!cnxcc_set_max_credit("$var(client)",
                                  "$var(credit)",
                                  "$var(cost_per_sec)",
                                  "$var(i_pulse)",
                                  "$var(f_pulse)")) {
                xlog("Error setting up credit control");
                return;
        }
        $var(count)     = -1;

        if (!cnxcc_get_channel_count("$var(client)", "$var(count)")) {
                xlog("Error getting customer's channel count");
        }

        xlog("L_INFO", "CNXCC ROUTE: $var(client) has $var(count) call(s)");

        if ($var(retcode) < -1) {
                xlog("Too many channels for customer");
                sl_send_reply(403, "Forbidden");

                if (!cnxcc_terminate_all("$var(client)")) {
                        xlog("Error terminating customer's calls");
                } else {
                        xlog("Terminating customer's call");
                }

                exit;
        }
}

route[SHOW_CHANNEL_COUNT]
{
        $var(count) = @cnxcc.channels["1000"].count;
        xlog("L_INFO", "1000 has $var(count) call(s)");
}

event_route[dialog:failed]
{
        xlog("dialog failed");
}

event_route[cnxcc:call-shutdown]
{
        xlog("L_INFO", "Shutting down channel by callcontroll");
        xlog("L_INFO", "[$ci]: call killed");
        $var(count)     = $var(count)-1;
        if (!cnxcc_get_channel_count("$var(client)", "$var(count)")) {
                xlog("Error getting customer's channel count");
        }
        xlog("L_INFO", "CNXCC ROUTE: $var(client) has $var(count) call(s)");
        # perform some kind of notification, database update, email sending, etc
}

Greetings
Andrzej Ciupek

Od: Carlos Ruiz Díaz
Wysłano: ‎sobota‎, ‎26‎ ‎kwietnia‎ ‎2014 ‎15‎:‎19
Do: Kamailio (SER) - Users Mailing List, Andrzej Ciupek

Hi,

sorry guys, I forgot about this. I will make my own tests and post the results.

Andrzej, can you post the configuration file you are using?

Regards,
Carlos


On Sat, Apr 26, 2014 at 4:15 AM, Kelvin Chua <kelchy@gmail.com> wrote:

No, I have not yet found the solution for this issue on my setup.

Maybe Carlos can help us out

On Apr 26, 2014 5:10 PM, "Andrzej Ciupek" <andrzej.ciupek@hotmail.com> wrote:
Hello
 
Have You solved this issue ?
I’am using Kamailio 4.1.3 and I’am getting the same results.
 
Greetings
Andrzej Ciupek

_______________________________________________
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




--



--
Carlos
http://caruizdiaz.com
http://ngvoice.com
+52 55 3048 3303