I'm glad that it worked.
Please don't forget to "git pull" to update your cnxcc copy.
Regards,
Carlos
On Mon, Apr 28, 2014 at 3:17 AM, Andrzej Ciupek
<andrzej.ciupek(a)hotmail.com> wrote:
Hello again
It works perfect, I was missing "setflag(DLG_FLAG);" in my main route.
Thank You very much for help.
Greetings
Andrzej Ciupek
________________________________
From: andrzej.ciupek(a)hotmail.com
To: carlos.ruizdiaz(a)gmail.com
CC: sr-users(a)lists.sip-router.org
Subject: RE: [SR-Users] cnxcc
Date: Mon, 28 Apr 2014 09:54:30 +0200
Hello
You are amazing !!
Your example work perfect, but I have to work with mine cfg, because
when I use part of Your route into my config it doesn't work like it should.
I think I have some problems with dialog module, because when I start
Your script I get:
Apr 28 09:47:31 kamailio /usr/local/sbin/kamailio[3060]: INFO: <script>:
dialog started
I don't see it using my config, so it looks like dialog module doesn't
work in my config file in proper way.
I will let You know when I find a bug in my script.
Now when I have working example it will be easier.
Greetings
Andrzej Ciupek
________________________________
Date: Sun, 27 Apr 2014 21:29:34 -0500
Subject: Re: [SR-Users] cnxcc
From: carlos.ruizdiaz(a)gmail.com
To: andrzej.ciupek(a)hotmail.com
CC: sr-users(a)lists.sip-router.org
Kelvin,
can you update your copy and try again? Maybe your problem was related
to this, or maybe not. In either case, I will try to reproduce your issue
later this week :).
Regards,
On Sun, Apr 27, 2014 at 9:27 PM, Carlos Ruiz Díaz
<carlos.ruizdiaz(a)gmail.com> wrote:
Hi Andrzej,
I found a deadlock situation using the script you posted, thanks to an
unusual way of using the functions that the module exports.
About the script itself: I found a few inconsistencies that would have
caused a problem with handing the calls even if there was no bug in the
software. For example:
- if you want to set the maximum amount of calls per user, use the
function "cnxcc_set_max_channel"
- the "call-shutdown" event route is only executed if the call runs out
of credit, never for "normal call clearing". For that, use
"dialog:end" or
"dialog:failed" instead.
- you cannot access "$var(client)" from outside the process that created
it. This means that when the call is killed, "$var(client)" will have a NULL
value since this event is processed by a completely different process. If
you want to have this information available everywhere, use a shared memory
variable instead ($sht).
I created a sample script [1] that applies your requirements in a
slightly different way:
- it authorizes the call by checking the balance
- it kills the call when the credit is over
- it doesn't allow more than one call per customer
[1]
https://gist.github.com/caruizdiaz/11359122
In this example I used a shared memory variable, to give you an idea of
how to persist the customer's ID across processes.
Regards,
Carlos
-
On Sat, Apr 26, 2014 at 10:34 AM, Carlos Ruiz Díaz
<carlos.ruizdiaz(a)gmail.com> wrote:
I did find a bug, using your config script, I will fix it this weekend.
Try with this configuration file [1].
[1]
https://gist.github.com/caruizdiaz/11323017
In summary, you can't use more than one check mechanisms. It has to be
credit, time or channels, exclusively.
Also, I need to test your config with Kam 4.1. I am using the trunk
version.
Regards,
On Sat, Apr 26, 2014 at 10:23 AM, Andrzej Ciupek
<andrzej.ciupek(a)hotmail.com> wrote:
Yes. I want prepaid subscribers be able to create only one channel to
prevent frauds for simultaneous calls.
Greetings
Andrzej Ciupek
________________________________
Od: Carlos Ruiz Díaz
Wysłano: 2014-04-26 16:42
Do: Andrzej Ciupek
DW: Kamailio (SER) - Users Mailing List
Temat: Re: [SR-Users] cnxcc
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(a)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(a)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(a)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(a)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
--
Carlos
http://caruizdiaz.com
http://ngvoice.com
+52 55 3048 3303
--
Carlos
http://caruizdiaz.com
http://ngvoice.com
+52 55 3048 3303
--
Carlos
http://caruizdiaz.com
http://ngvoice.com
+52 55 3048 3303
--
Carlos
http://caruizdiaz.com
http://ngvoice.com
+52 55 3048 3303
+52 55 3048 3303
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users(a)lists.sip-router.org