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.ruizd...@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.ruizd...@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.ciu...@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 <carlos.ruizd...@gmail.com> >>> Wysłano: 2014-04-26 16:42 >>> Do: Andrzej Ciupek <andrzej.ciu...@hotmail.com> >>> DW: Kamailio (SER) - Users Mailing List <sr-users@lists.sip-router.org> >>> 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.ciu...@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 <carlos.ruizd...@gmail.com> >>> *Wysłano:* sobota, 26 kwietnia 2014 15:19 >>> *Do:* Kamailio (SER) - Users Mailing List<sr-users@lists.sip-router.org>, >>> Andrzej Ciupek <andrzej.ciu...@hotmail.com> >>> >>> 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 <kel...@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.ciu...@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 >>> >>> >>> >>> >>> -- >>> 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
_______________________________________________ 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