[Freeswitch-users] nibblebill do not terminate calls properly

Tanguy phenix at vfemail.net
Sun Apr 10 15:21:12 MSD 2016

I would like to use nibblebilling for fraud prevention on international 
and premium numbers ( national or emergency calls should never be 
blocked and should still working even if the billing database is 
unavailable  )

Unfortunately that never hangup my calls using standard dial plan


<configuration name="nibblebill.conf" description="Nibble Billing">
     <!-- See http://wiki.freeswitch.org/wiki/Mod_nibblebill for help 
with these options -->

     <!-- Information for connecting to your database -->
     <param name="db_dsn" value="pgsql://hostaddr= dbname=xxxx 
user=xxxx password=xxxx"/>

     <!-- The database table where your CASH column is located -->
     <param name="db_table" value="accounts"/>

     <!-- The column name where we store the value of the account -->
     <param name="db_column_cash" value="cash"/>

     <!-- The column name for the unique ID identifying the account -->
     <param name="db_column_account" value="id"/>

     <!-- Default heartbeat interval. Set to 'off' for no heartbeat 
(i.e. bill only at end of call) -->
     <param name="global_heartbeat" value="20"/>

     <!-- By default, warn a caller when their balance is at $5.00. You 
can set this to a negative number. -->
     <param name="lowbal_amt" value="-100"/><!-- i don't need this -->
     <param name="lowbal_action" value="play ding"/>

     <!-- By default, terminate a caller when their balance hits $0.00. 
You can set this to a negative number. -->
     <param name="nobal_amt" value="0"/>
     <param name="nobal_action" value="hangup"/>

     <!-- If a call goes beyond a certain dollar amount, flag or 
terminate it -->
     <param name="percall_max_amt" value="10"/>
     <param name="percall_action" value="hangup"/>


*outbound route*

<extension name="international" >
    <condition field="destination_number" expression="^00(\d{6,20})$" >
        <action application="nibblebill" data="flush"/>
         <action application="set" data="nibble_account=${accountcode}"/>
         <action application="set" data="nibble_rate=0.1"/>
        <action application="bridge" data="sofia/gateway/gw_idt/$1" />

*My balance*
My balance is already negative

  select * from accounts ;
                 id                |   cash
  company.voip.mydomain.com | -0.789471

*A sample call*
My balance already negative, the call will be billed but never blocked

Dialplan: sofia/internal/5003 at company.voip.domain.com Action 
Dialplan: sofia/internal/5003 at company.voip.domain.com Action 
Dialplan: sofia/internal/5003 at company.voip.domain.com Action 
EXECUTE sofia/internal/5003 at company.voip.domain.com nibblebill(flush)
EXECUTE sofia/internal/5003 at company.voip.domain.com 
2016-04-10 12:10:04.049418 [DEBUG] mod_dptools.c:1477 
sofia/internal/5003 at company.voip.domain.com SET 
EXECUTE sofia/internal/5003 at company.voip.domain.com set(nibble_rate=0.1)
2016-04-10 12:10:04.049418 [DEBUG] mod_dptools.c:1477 
sofia/internal/5003 at company.voip.domain.com SET [nibble_rate]=[0.1]
2016-04-10 12:10:52.132458 [DEBUG] mod_nibblebill.c:488 Attempting to 
bill at $0.1 per minute to account company.voip.domain.com
2016-04-10 12:10:52.132458 [INFO] mod_nibblebill.c:540 Beginning new 
billing on 644488fc-ff04-11e5-9a27-fd2791153af9
2016-04-10 12:10:52.132458 [DEBUG] mod_nibblebill.c:546 42 seconds 
passed since last bill time of 2016-04-10 12:10:09
2016-04-10 12:10:52.132458 [DEBUG] mod_nibblebill.c:563 Billing 
$0.071033 to company.voip.domain.com (Call: / 0.000000 so far)
2016-04-10 12:10:52.132458 [DEBUG] mod_nibblebill.c:393 Doing update query
2016-04-10 12:10:52.172440 [DEBUG] mod_nibblebill.c:420 Doing lookup query
[SELECT cash AS nibble_balance FROM accounts WHERE 
2016-04-10 12:10:52.172440 [DEBUG] mod_nibblebill.c:428 Retrieved 
current balance for account company.voip.domain.com (balance = -0.860504)

*Using b-leg only*
Alternatively i tried an alternative dialplan ( Even if i don't relay 
understand what is the meaning of b-leg billing  )

<action application="bridge" 

The result is better because the pending call is hanged up when the 
balance reach 0.

2016-04-10 12:39:59.012462 [CRIT] mod_nibblebill.c:607 Balance of 
-0.003237 fell below allowed amount of 0.000000! (Account 

But if i make a new call ( when my balance is negative )  , the caller 
party is immediately hanged but this did not cancel immediately the 
bridge:  The called party ring and can stay bridged for 61 seconds after 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20160410/d00b3b28/attachment-0001.html 

Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list