<div dir="ltr">Hi Kelvin,<div><br></div><div>thank you for the feedback. This will surely help others to troubleshoot their problems :).</div><div><br></div><div>Regards,</div><div>Carlos</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Mon, Jun 2, 2014 at 9:49 PM, Kelvin Chua <span dir="ltr"><<a href="mailto:kelchy@gmail.com" target="_blank">kelchy@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
hi guys,<br>
just to close this issue, i figured the problem only affects scenarios<br>
where dlg_manage() comes before cnxcc_set_max_credits()<br>
Kelvin Chua<br>
<br>
<br>
On Mon, May 12, 2014 at 10:00 AM, Carlos Ruiz Díaz<br>
<div class="HOEnZb"><div class="h5"><<a href="mailto:carlos.ruizdiaz@gmail.com">carlos.ruizdiaz@gmail.com</a>> wrote:<br>
> Hi,<br>
><br>
> Check this commitdiff [1], it has some subtle lines of code that remove the<br>
> deadlock.<br>
><br>
> Rtimer is not required, it is only used in the sample configuration file to<br>
> display the amount of concurrent calls and to grant more time when needed,<br>
> but strictly in the business logic sense. Internally, dialog is the only<br>
> module that is a dependency.<br>
><br>
> [1]<br>
> <a href="http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=commitdiff;h=d0f0ba702bd44524bc9f52e07341db03267b15f7" target="_blank">http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=commitdiff;h=d0f0ba702bd44524bc9f52e07341db03267b15f7</a><br>

><br>
> Regards,<br>
> Carlos<br>
><br>
><br>
><br>
> On Sun, May 11, 2014 at 9:57 AM, Kelvin Chua <<a href="mailto:kelchy@gmail.com">kelchy@gmail.com</a>> wrote:<br>
>><br>
>> hi carlos,<br>
>><br>
>> i'm looking at the commitdiff, seems like it's just indentations<br>
>><br>
>> <a href="http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=commitdiff;h=d0f0ba702bd44524bc9f52e07341db03267b15f7" target="_blank">http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=commitdiff;h=d0f0ba702bd44524bc9f52e07341db03267b15f7</a><br>

>> is there something i am missing?<br>
>><br>
>> by the way, based on the module documentation, the only dependency is the<br>
>> dialog module, shouldn't it include the rtimer module?<br>
>> is it really required? what if i would only use CNXCC_MONEY and not<br>
>> CNXCC_TIME or CNXCC_CHANNEL? should i still load<br>
>> rtimer.so before loading cnxcc.so?<br>
>><br>
>> Kelvin Chua<br>
>><br>
>><br>
>> On Mon, Apr 28, 2014 at 9:13 PM, Carlos Ruiz Díaz<br>
>> <<a href="mailto:carlos.ruizdiaz@gmail.com">carlos.ruizdiaz@gmail.com</a>> wrote:<br>
>>><br>
>>> I'm glad that it worked.<br>
>>><br>
>>> Please don't forget to "git pull" to update your cnxcc copy.<br>
>>><br>
>>> Regards,<br>
>>> Carlos<br>
>>><br>
>>><br>
>>> On Mon, Apr 28, 2014 at 3:17 AM, Andrzej Ciupek<br>
>>> <<a href="mailto:andrzej.ciupek@hotmail.com">andrzej.ciupek@hotmail.com</a>> wrote:<br>
>>>><br>
>>>> Hello again<br>
>>>><br>
>>>> It works perfect, I was missing "setflag(DLG_FLAG);" in my main route.<br>
>>>><br>
>>>> Thank You very much for help.<br>
>>>><br>
>>>> Greetings<br>
>>>> Andrzej Ciupek<br>
>>>><br>
>>>> ________________________________<br>
>>>> From: <a href="mailto:andrzej.ciupek@hotmail.com">andrzej.ciupek@hotmail.com</a><br>
>>>> To: <a href="mailto:carlos.ruizdiaz@gmail.com">carlos.ruizdiaz@gmail.com</a><br>
>>>> CC: <a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
>>>> Subject: RE: [SR-Users] cnxcc<br>
>>>> Date: Mon, 28 Apr 2014 09:54:30 +0200<br>
>>>><br>
>>>><br>
>>>> Hello<br>
>>>><br>
>>>> You are amazing !!<br>
>>>><br>
>>>> Your example work perfect, but I have to work with mine cfg, because<br>
>>>> when I use part of Your route into my config it doesn't work like it should.<br>
>>>> I think I have some problems with dialog module, because when I start<br>
>>>> Your script I get:<br>
>>>><br>
>>>> Apr 28 09:47:31 kamailio /usr/local/sbin/kamailio[3060]: INFO: <script>:<br>
>>>> dialog started<br>
>>>><br>
>>>> I don't see it using my config, so it looks like dialog module doesn't<br>
>>>> work in my config file in proper way.<br>
>>>> I will let You know when I find a bug in my script.<br>
>>>><br>
>>>> Now when I have working example it will be easier.<br>
>>>><br>
>>>> Greetings<br>
>>>> Andrzej Ciupek<br>
>>>><br>
>>>> ________________________________<br>
>>>> Date: Sun, 27 Apr 2014 21:29:34 -0500<br>
>>>> Subject: Re: [SR-Users] cnxcc<br>
>>>> From: <a href="mailto:carlos.ruizdiaz@gmail.com">carlos.ruizdiaz@gmail.com</a><br>
>>>> To: <a href="mailto:andrzej.ciupek@hotmail.com">andrzej.ciupek@hotmail.com</a><br>
>>>> CC: <a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
>>>><br>
>>>> Kelvin,<br>
>>>><br>
>>>> can you update your copy and try again? Maybe your problem was related<br>
>>>> to this, or maybe not. In either case, I will try to reproduce your issue<br>
>>>> later this week :).<br>
>>>><br>
>>>> Regards,<br>
>>>><br>
>>>><br>
>>>> On Sun, Apr 27, 2014 at 9:27 PM, Carlos Ruiz Díaz<br>
>>>> <<a href="mailto:carlos.ruizdiaz@gmail.com">carlos.ruizdiaz@gmail.com</a>> wrote:<br>
>>>><br>
>>>> Hi Andrzej,<br>
>>>><br>
>>>> I found a deadlock situation using the script you posted, thanks to an<br>
>>>> unusual way of using the functions that the module exports.<br>
>>>><br>
>>>> About the script itself: I found a few inconsistencies that would have<br>
>>>> caused a problem with handing the calls even if there was no bug in the<br>
>>>> software. For example:<br>
>>>><br>
>>>> - if you want to set the maximum amount of calls per user, use the<br>
>>>> function "cnxcc_set_max_channel"<br>
>>>><br>
>>>> - the "call-shutdown" event route is only executed if the call runs out<br>
>>>> of credit, never for "normal call clearing". For that, use "dialog:end" or<br>
>>>> "dialog:failed" instead.<br>
>>>><br>
>>>> - you cannot access "$var(client)" from outside the process that created<br>
>>>> it. This means that when the call is killed, "$var(client)" will have a NULL<br>
>>>> value since this event is processed by a completely different process. If<br>
>>>> you want to have this information available everywhere, use a shared memory<br>
>>>> variable instead ($sht).<br>
>>>><br>
>>>> I created a sample script [1] that applies your requirements in a<br>
>>>> slightly different way:<br>
>>>><br>
>>>> - it authorizes the call by checking the balance<br>
>>>> - it kills the call when the credit is over<br>
>>>> - it doesn't allow more than one call per customer<br>
>>>><br>
>>>> [1] <a href="https://gist.github.com/caruizdiaz/11359122" target="_blank">https://gist.github.com/caruizdiaz/11359122</a><br>
>>>><br>
>>>> In this example I used a shared memory variable, to give you an idea of<br>
>>>> how to persist the customer's ID across processes.<br>
>>>><br>
>>>> Regards,<br>
>>>> Carlos<br>
>>>><br>
>>>> -<br>
>>>><br>
>>>><br>
>>>><br>
>>>><br>
>>>> On Sat, Apr 26, 2014 at 10:34 AM, Carlos Ruiz Díaz<br>
>>>> <<a href="mailto:carlos.ruizdiaz@gmail.com">carlos.ruizdiaz@gmail.com</a>> wrote:<br>
>>>><br>
>>>> I did find a bug, using your config script, I will fix it this weekend.<br>
>>>> Try with this configuration file [1].<br>
>>>><br>
>>>> [1] <a href="https://gist.github.com/caruizdiaz/11323017" target="_blank">https://gist.github.com/caruizdiaz/11323017</a><br>
>>>><br>
>>>> In summary, you can't use more than one check mechanisms. It has to be<br>
>>>> credit, time or channels, exclusively.<br>
>>>><br>
>>>> Also, I need to test your config with Kam 4.1. I am using the trunk<br>
>>>> version.<br>
>>>><br>
>>>> Regards,<br>
>>>><br>
>>>><br>
>>>> On Sat, Apr 26, 2014 at 10:23 AM, Andrzej Ciupek<br>
>>>> <<a href="mailto:andrzej.ciupek@hotmail.com">andrzej.ciupek@hotmail.com</a>> wrote:<br>
>>>><br>
>>>> Yes. I want prepaid subscribers be able to create only one channel to<br>
>>>> prevent frauds for simultaneous calls.<br>
>>>><br>
>>>> Greetings<br>
>>>> Andrzej Ciupek<br>
>>>> ________________________________<br>
>>>> Od: Carlos Ruiz Díaz<br>
>>>> Wysłano: ‎2014-‎04-‎26 16:42<br>
>>>> Do: Andrzej Ciupek<br>
>>>> DW: Kamailio (SER) - Users Mailing List<br>
>>>> Temat: Re: [SR-Users] cnxcc<br>
>>>><br>
>>>> Hi Andrzej,<br>
>>>><br>
>>>> are you trying to setup cnxcc to check both credit and maximum<br>
>>>> simultaneous calls?<br>
>>>><br>
>>>> Regards,<br>
>>>><br>
>>>><br>
>>>><br>
>>>> On Sat, Apr 26, 2014 at 9:26 AM, Andrzej Ciupek<br>
>>>> <<a href="mailto:andrzej.ciupek@hotmail.com">andrzej.ciupek@hotmail.com</a>> wrote:<br>
>>>><br>
>>>> Hello<br>
>>>><br>
>>>> I’am using default config with options from an example. It looks like<br>
>>>> event route isn’t execuded after hangup.<br>
>>>><br>
>>>> Apr 26 16:26:14 kamailio /usr/local/sbin/kamailio[4611]: INFO: <script>:<br>
>>>> 1000 has 1 call(s)<br>
>>>> Apr 26 16:26:15 kamailio /usr/local/sbin/kamailio[4611]: INFO: <script>:<br>
>>>> 1000 has 1 call(s)<br>
>>>> Apr 26 16:26:16 kamailio /usr/local/sbin/kamailio[4611]: INFO: <script>:<br>
>>>> 1000 has 1 call(s)<br>
>>>> Apr 26 16:26:17 kamailio /usr/local/sbin/kamailio[4611]: INFO: <script>:<br>
>>>> 1000 has 1 call(s)<br>
>>>> Apr 26 16:26:18 kamailio /usr/local/sbin/kamailio[4611]: INFO: <script>:<br>
>>>> 1000 has 1 call(s)<br>
>>>> Apr 26 16:26:19 kamailio /usr/local/sbin/kamailio[4611]: INFO: <script>:<br>
>>>> 1000 has 1 call(s)<br>
>>>> Apr 26 16:26:20 kamailio /usr/local/sbin/kamailio[4611]: INFO: <script>:<br>
>>>> 1000 has 1 call(s)<br>
>>>> Apr 26 16:26:20 kamailio /usr/local/sbin/kamailio[4604]: INFO: <script>:<br>
>>>> Setting up money based credit control<br>
>>>> Apr 26 16:26:20 kamailio /usr/local/sbin/kamailio[4604]: INFO: <script>:<br>
>>>> Setting up channel based credit control<br>
>>>> Apr 26 16:26:20 kamailio /usr/local/sbin/kamailio[4604]: INFO: <script>:<br>
>>>> CNXCC ROUTE: 1000 has 2 call(s)<br>
>>>><br>
>>>> kamailio.cfg<br>
>>>> …<br>
>>>> …<br>
>>>> # ----- prepaid call controll -----<br>
>>>><br>
>>>> #!define DLG_FLAG 28<br>
>>>> #!define CC_FLAG 29<br>
>>>><br>
>>>> loadmodule "dialog.so"<br>
>>>><br>
>>>> modparam("dialog", "hash_size", 2048)<br>
>>>> modparam("dialog", "default_timeout", 3600)<br>
>>>> modparam("dialog", "db_mode", 0)<br>
>>>> modparam("dialog", "dlg_flag", DLG_FLAG)<br>
>>>><br>
>>>> modparam("rtimer", "timer", "name=ta;interval=1;mode=1;")<br>
>>>> modparam("rtimer", "exec", "timer=ta;route=SHOW_CHANNEL_COUNT")<br>
>>>><br>
>>>> loadmodule "cnxcc.so"<br>
>>>><br>
>>>> modparam("cnxcc", "dlg_flag", CC_FLAG)<br>
>>>> modparam("cnxcc", "credit_check_period", 1) #check every 1 second<br>
>>>><br>
>>>> …<br>
>>>> …<br>
>>>> …<br>
>>>> route {<br>
>>>> …<br>
>>>> …<br>
>>>>  if (!allow_source_address("2") and !allow_source_address("1")){<br>
>>>>         route(CNXCC);<br>
>>>>         route(PSTN);<br>
>>>>         }<br>
>>>> …<br>
>>>> }<br>
>>>><br>
>>>> route[CNXCC]<br>
>>>> {<br>
>>>><br>
>>>>         $var(client)            = "1000";<br>
>>>><br>
>>>>         xlog("L_INFO", "Setting up money based credit control");<br>
>>>><br>
>>>>         $var(credit)            = "10"; # 10$ of credit<br>
>>>>         $var(cost_per_sec)      = "1";  # 1$ per sec<br>
>>>>         $var(i_pulse)           = "1";  # 1$ to establish the call<br>
>>>>         $var(f_pulse)           = "1";  # 1$ per second<br>
>>>><br>
>>>>         # if only one call is established, that call should last 9<br>
>>>> seconds.<br>
>>>><br>
>>>>         if (!cnxcc_set_max_credit("$var(client)",<br>
>>>>                                   "$var(credit)",<br>
>>>>                                   "$var(cost_per_sec)",<br>
>>>>                                   "$var(i_pulse)",<br>
>>>>                                   "$var(f_pulse)")) {<br>
>>>>                 xlog("Error setting up credit control");<br>
>>>>                 return;<br>
>>>>         }<br>
>>>>         $var(count)     = -1;<br>
>>>><br>
>>>>         if (!cnxcc_get_channel_count("$var(client)", "$var(count)")) {<br>
>>>>                 xlog("Error getting customer's channel count");<br>
>>>>         }<br>
>>>><br>
>>>>         xlog("L_INFO", "CNXCC ROUTE: $var(client) has $var(count)<br>
>>>> call(s)");<br>
>>>><br>
>>>>         if ($var(retcode) < -1) {<br>
>>>>                 xlog("Too many channels for customer");<br>
>>>>                 sl_send_reply(403, "Forbidden");<br>
>>>><br>
>>>>                 if (!cnxcc_terminate_all("$var(client)")) {<br>
>>>>                         xlog("Error terminating customer's calls");<br>
>>>>                 } else {<br>
>>>>                         xlog("Terminating customer's call");<br>
>>>>                 }<br>
>>>><br>
>>>>                 exit;<br>
>>>>         }<br>
>>>> }<br>
>>>><br>
>>>> route[SHOW_CHANNEL_COUNT]<br>
>>>> {<br>
>>>>         $var(count) = @cnxcc.channels["1000"].count;<br>
>>>>         xlog("L_INFO", "1000 has $var(count) call(s)");<br>
>>>> }<br>
>>>><br>
>>>> event_route[dialog:failed]<br>
>>>> {<br>
>>>>         xlog("dialog failed");<br>
>>>> }<br>
>>>><br>
>>>> event_route[cnxcc:call-shutdown]<br>
>>>> {<br>
>>>>         xlog("L_INFO", "Shutting down channel by callcontroll");<br>
>>>>         xlog("L_INFO", "[$ci]: call killed");<br>
>>>>         $var(count)     = $var(count)-1;<br>
>>>>         if (!cnxcc_get_channel_count("$var(client)", "$var(count)")) {<br>
>>>>                 xlog("Error getting customer's channel count");<br>
>>>>         }<br>
>>>>         xlog("L_INFO", "CNXCC ROUTE: $var(client) has $var(count)<br>
>>>> call(s)");<br>
>>>>         # perform some kind of notification, database update, email<br>
>>>> sending, etc<br>
>>>> }<br>
>>>><br>
>>>> Greetings<br>
>>>> Andrzej Ciupek<br>
>>>><br>
>>>> Od: Carlos Ruiz Díaz<br>
>>>> Wysłano: ‎sobota‎, ‎26‎ ‎kwietnia‎ ‎2014 ‎15‎:‎19<br>
>>>> Do: Kamailio (SER) - Users Mailing List, Andrzej Ciupek<br>
>>>><br>
>>>> Hi,<br>
>>>><br>
>>>> sorry guys, I forgot about this. I will make my own tests and post the<br>
>>>> results.<br>
>>>><br>
>>>> Andrzej, can you post the configuration file you are using?<br>
>>>><br>
>>>> Regards,<br>
>>>> Carlos<br>
>>>><br>
>>>><br>
>>>> On Sat, Apr 26, 2014 at 4:15 AM, Kelvin Chua <<a href="mailto:kelchy@gmail.com">kelchy@gmail.com</a>> wrote:<br>
>>>><br>
>>>> No, I have not yet found the solution for this issue on my setup.<br>
>>>><br>
>>>> Maybe Carlos can help us out<br>
>>>><br>
>>>> On Apr 26, 2014 5:10 PM, "Andrzej Ciupek" <<a href="mailto:andrzej.ciupek@hotmail.com">andrzej.ciupek@hotmail.com</a>><br>
>>>> wrote:<br>
>>>><br>
>>>> Hello<br>
>>>><br>
>>>> Have You solved this issue ?<br>
>>>> I’am using Kamailio 4.1.3 and I’am getting the same results.<br>
>>>><br>
>>>> Greetings<br>
>>>> Andrzej Ciupek<br>
>>>><br>
>>>><br>
>>>> _______________________________________________<br>
>>>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>
>>>> <a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
>>>> <a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
>>>><br>
>>>><br>
>>>><br>
>>>><br>
>>>> --<br>
>>>> Carlos<br>
>>>> <a href="http://caruizdiaz.com" target="_blank">http://caruizdiaz.com</a><br>
>>>> <a href="http://ngvoice.com" target="_blank">http://ngvoice.com</a><br>
>>>> <a href="tel:%2B52%2055%203048%203303" value="+525530483303">+52 55 3048 3303</a><br>
>>>><br>
>>>><br>
>>>><br>
>>>><br>
>>>> --<br>
>>>> Carlos<br>
>>>> <a href="http://caruizdiaz.com" target="_blank">http://caruizdiaz.com</a><br>
>>>> <a href="http://ngvoice.com" target="_blank">http://ngvoice.com</a><br>
>>>> <a href="tel:%2B52%2055%203048%203303" value="+525530483303">+52 55 3048 3303</a><br>
>>>><br>
>>>><br>
>>>><br>
>>>><br>
>>>> --<br>
>>>> Carlos<br>
>>>> <a href="http://caruizdiaz.com" target="_blank">http://caruizdiaz.com</a><br>
>>>> <a href="http://ngvoice.com" target="_blank">http://ngvoice.com</a><br>
>>>> <a href="tel:%2B52%2055%203048%203303" value="+525530483303">+52 55 3048 3303</a><br>
>>>><br>
>>>><br>
>>>><br>
>>>><br>
>>>> --<br>
>>>> Carlos<br>
>>>> <a href="http://caruizdiaz.com" target="_blank">http://caruizdiaz.com</a><br>
>>>> <a href="http://ngvoice.com" target="_blank">http://ngvoice.com</a><br>
>>>> <a href="tel:%2B52%2055%203048%203303" value="+525530483303">+52 55 3048 3303</a><br>
>>>><br>
>>>><br>
>>>><br>
>>>><br>
>>>> --<br>
>>>> Carlos<br>
>>>> <a href="http://caruizdiaz.com" target="_blank">http://caruizdiaz.com</a><br>
>>>> <a href="http://ngvoice.com" target="_blank">http://ngvoice.com</a><br>
>>>> <a href="tel:%2B52%2055%203048%203303" value="+525530483303">+52 55 3048 3303</a><br>
>>><br>
>>><br>
>>><br>
>>><br>
>>> --<br>
>>> Carlos<br>
>>> <a href="http://caruizdiaz.com" target="_blank">http://caruizdiaz.com</a><br>
>>> <a href="http://ngvoice.com" target="_blank">http://ngvoice.com</a><br>
>>> <a href="tel:%2B52%2055%203048%203303" value="+525530483303">+52 55 3048 3303</a><br>
>>><br>
>>> _______________________________________________<br>
>>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>
>>> <a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
>>> <a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
>>><br>
>><br>
>><br>
>> _______________________________________________<br>
>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>
>> <a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
>> <a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
>><br>
><br>
><br>
><br>
> --<br>
> Carlos<br>
> <a href="http://caruizdiaz.com" target="_blank">http://caruizdiaz.com</a><br>
> <a href="http://ngvoice.com" target="_blank">http://ngvoice.com</a><br>
> <a href="tel:%2B52%2055%203048%203303" value="+525530483303">+52 55 3048 3303</a><br>
><br>
> _______________________________________________<br>
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>
> <a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
> <a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
><br>
<br>
_______________________________________________<br>
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>
<a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Carlos<div><a href="http://caruizdiaz.com" target="_blank">http://caruizdiaz.com</a></div><div><a href="http://ngvoice.com" target="_blank">http://ngvoice.com</a></div>
<div>+52 55 3048 3303</div></div>
</div>