Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
Hello, I'm still stuck with Nibblebill config. Even if the current balance is 0 or negative, the dialplan start the call. Someone would have some examples of config where this behaviour is avoided? Thank you! Regards, Igor. De : igor.potjevlesch@gmail.com [mailto:igor.potjevlesch@gmail.com] Envoyé : mercredi 10 janvier 2018 15:49 À : 'Madovsky' <infos@madovsky.org> Objet : RE: [Freeswitch-users] Use Nibblebill with PostgreSQL This is the log: Action log(INFO ${nibble_balance} is equal or lower than 0) With or without "set nibble_balance". So I guess that this variable is undefined. De : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> [mailto:igor.potjevlesch@gmail.com] Envoyé : mercredi 10 janvier 2018 15:39 À : 'Madovsky' <infos@madovsky.org <mailto:infos@madovsky.org> > Objet : RE: [Freeswitch-users] Use Nibblebill with PostgreSQL I don't understand what is supposed to do the SQL request? I think that, indeed, nibble_balance is not set at the moment of the condition. De : Madovsky [mailto:infos@madovsky.org] Envoyé : mardi 9 janvier 2018 21:24 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL you should remove <action application="set" data="nibble_balance" inline="true"/> since when you populate nibble_account it makes automatically the SQL request and populate nibble_balance. then don't forget to put all nibble variables on the bridge like {nibble_account=${nibble_account},etc.}sofia/xxx On 1/9/2018 8:14 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: I didn't. What does it mean "inline" in that case? I tried like this and add "inline" on all settings. So, now the dialplan looks like this: <action application="set" data="nibble_account=1" inline="true"/> <action application="set" data="nibble_rate=1" inline="true"/> <action application="set" data="nibble_minimum=1" inline="true"/> <action application="set" data="nibble_rounding=2" inline="true"/> <action application="set" data="nibble_balance" inline="true"/> <action application="nibblebill" data="heartbeat 1"/> <condition break="on-true" field="${cond(${nibble_balance} <= 0 ? YES : NO)}" expression="^YES$"> <action application="log" data="INFO ${nibble_balance} is equal or lower than 0"/> </condition> <action application="bridge" data="{nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/outbound/0$1"/> The logs are showing the following outputs and the call start: 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_account=1) INLINE 8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_account=1) 8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_account]=[1] 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_rate=1) INLINE 8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_rate=1) 8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_rate]=[1] 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_minimum=1) INLINE 8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_minimum=1) 8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_minimum]=[1] 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_rounding=2) INLINE 8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_rounding=2) 8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_rounding]=[2] 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_balance) INLINE 8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_balance) 8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_balance]=[UNDEF] 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action nibblebill(heartbeat 1) 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action bridge({nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=}sofia/gateway/out/0123456789) 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action hangup(hangup_cause) De : Madovsky [mailto:infos@madovsky.org] Envoyé : lundi 8 janvier 2018 19:52 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL did you set nibble balance inline="true" before the condition? also check with log just after you set the var to be sure the SQL return a value On 1/8/2018 10:24 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: I basically tried this: <condition break="on-true" field="${cond(${nibble_balance} <= 0 ? YES : NO)}" expression="^YES$"> <action application="log" data="INFO ${nibble_balance} is equal or lower than 0"/> </condition> But I didn't see anything in the logs, the call begin to start. Regards, Igor De : Madovsky [mailto:infos@madovsky.org] Envoyé : vendredi 5 janvier 2018 14:44 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL Yes in a nested condition for ex. this method is more robust that trust nibblebill to do all the job On 1/5/2018 5:33 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: It means that I can test ${nibble_balance} before right? De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 20:31 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL you should make a nested condition before the bridge and if the balance not good transfer the call to hangup or something else On 1/4/2018 8:03 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: I uncommented this in the config file of nibblebill: <param name="custom_sql_lookup" value="SELECT euros AS nibble_balance FROM solde WHERE customer_id='${nibble_account}'"/> The request is working fine according to the logs, but the call is still placed with the logs: 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:422 Doing lookup query [SELECT euros AS nibble_balance FROM solde WHERE customer_id='1'] 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:430 Retrieved current balance for account 1 (balance = -0.040000) 31fe25c6-f168-11e7-a065-b10720ff818b 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:523 Comparing -0.040000 to hangup balance of 1.000000, taking into account minimum charge of 1.000000 31fe25c6-f168-11e7-a065-b10720ff818b 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:526 Balance of -0.040000 fell below allowed amount of 1.000000! (Account 1) De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 16:37 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL add an sql request into nibblebill and link it to nibble_balance variables inline in diaplan On 1/4/2018 7:35 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: Yes, why not, but I don't find how to check the balance before a bridge. De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 16:29 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL it starts because you don't have any user linked to your nibble_account so the only way to not start the call is to create a condition with the nibble balance before the bridge On 1/4/2018 7:22 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: I did this: dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_account=1) dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1 /+4425482090@A.B.C.D <mailto:/+4425482090@A.B.C.D> Action set(nibble_rate=1) dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_minimum=1) dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_rounding=2) dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action nibblebill(heartbeat 1) dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D Action bridge({nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=}sofia/gateway/out_1/0123456789) […] 2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:430 Retrieved current balance for account 1 (balance = 0.000000) dca7b05c-f161-11e7-9f9a-b10720ff818b 2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:523 Comparing 0.000000 to hangup balance of 1.000000, taking into account minimum charge of 1.000000 dca7b05c-f161-11e7-9f9a-b10720ff818b 2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:526 Balance of 0.000000 fell below allowed amount of 1.000000! (Account 1) But the call still starts. De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 16:09 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL the nibblebill variables must be on the bridge like <action application="bridge" data="{nibble_account=1,nibble_rate=1,etc....absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/out_01/0$1"/> do not use "export" since I noticed some strange behavior with it. I don't know how nibblebill behaves without a nibble_account linked to a user account, so I cannot help for this case On 1/4/2018 7:06 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: I don't have a registered user. It's a peer trusted by his IP address. During the call the credit is updated every seconds but even without credit, the call start and stop immediately. Yes I know. I will switch to more reasonable value after my tests. What do you mean by "export all nibblebill variables to the bridge"? De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 15:52 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
<action application="set" data="nibble_account=1"/>
is 1 a valid nibble_account of a registered user?
<action application="nibblebill" data="check"/>
you dont' need to check, as nibblebill automatically check the balance if the nibble_account is linked to a registered user
<action application="nibblebill" data="heartbeat 1"/>
be aware that heartbeat to 1 means a request to your DB every second about your issue you should export all nibblebill variables to the bridge too On 1/4/2018 6:46 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: That's the case: <condition break="on-true" expression="^\+44([1-9][0-9]{8})$" field="destination_number"> <action application="set" data="nibble_account=1"/> <action application="nibblebill" data="check"/> <action application="set" data="nibble_rate=1"/> <action application="set" data="nibble_minimum=1"/> <action application="set" data="nibble_rounding=2"/> <action application="nibblebill" data="heartbeat 1"/> <action application="bridge" data="{absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/out_01/0$1"/> <action application="hangup" data="hangup_cause"/> </condition> De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 12:41 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL you must check or set nibble_account before the call On 1/4/2018 3:35 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: Hello, Finally the billing works good. Would it be possible to setup the rates in db? I don't find example or documentation related to this. Also, I don't understand why the call is allowed for bridging whereas the balance is 0 or negative? Regards, Igor. De : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> [mailto:igor.potjevlesch@gmail.com] Envoyé : jeudi 4 janvier 2018 10:19 À : 'FreeSWITCH Users Help' <mailto:freeswitch-users@lists.freeswitch.org> <freeswitch-users@lists.freeswitch.org> Objet : RE: [Freeswitch-users] Use Nibblebill with PostgreSQL Hello, Thank you! Both db_dsn and odbc-dsn work. db-dsn fails. I keep the version with odbc-dsn because in that case I don't have the warning about deprecated function for versions earlier than 1.4.2 even if I run 1.6. What is the best according to you? db_dsn or odbc-dsn? I have additional questions related to nibble: 1. After hanging up the call, I see in the logs the good value: "mod_nibblebill.c:590 Billing $0.000234" but some line after there is another update: "mod_nibblebill.c:622 Rounding to precision 1.000000, total 1.000000 (0.999793 excess)". So the call is billed 1 instead of 0.000234. 2. Is it possible to setup in the db scheme different prefixes and their rate? Instead of putting them raw in the dialplan or any other config file? Thank you in advance for your clarification. Regards, Igor. De : FreeSWITCH-users [mailto:freeswitch-users-bounces@lists.freeswitch.org] De la part de Madovsky Envoyé : mercredi 3 janvier 2018 22:18 À : freeswitch-users@lists.freeswitch.org <mailto:freeswitch-users@lists.freeswitch.org> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL If you compiled FS with --enable-core-odbc-support so you can use <param name="odbc-dsn" value="pgsql://hostaddr=xx.xx.xx.xx port=xxxx dbname=xxx user=xxx password='xxxx' options='-c client_min_messages=NOTICE' application_name='freeswitch'" /> you must set odbc.ini On 1/3/2018 1:02 PM, Geoff Mina wrote: I think the param is db-dsn. Not the underscore version. On Jan 3, 2018, at 12:59 PM, Sergey Safarov <s.safarov@gmail.com <mailto:s.safarov@gmail.com> > wrote: I used connection string <param name="db_dsn" value="pgsql://hostaddr=127.0.0.1 dbname=******* user=******* password=*******"/> Sergey ср, 3 янв. 2018 г. в 22:06, <igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> >: Hello ! I try to connect Nibblebill directly to PostgreSQL but it still fails. I follow the documentation and setup the param like this: <param name="odbc_dsn" value="pgsql://A.B.C.D dbname=prepaid user=prepaid password=<hidden>"/> When I hangup a call, the logs report the following: 52c8b77c-f0b8-11e7-8d19-5566a3fb77f6 2018-01-03 20:00:19.037333 [CRIT] mod_nibblebill.c:604 Failed to log to database! Any idea on how to proceed with FS 1.6? Thank you! Regards, Igor. _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
I don't understand what is supposed to do the SQL request? I think that, indeed, nibble_balance is not set at the moment of the condition.
when you set the nibble account so nibblebill makes the SQL request you set in its config to populate nibble_current_balance, so if you make a condition with nibble_current_balance just after set nibble_account so you should set it inline to make the condition available On 1/15/2018 5:29 AM, igor.potjevlesch@gmail.com wrote:
Hello,
I'm still stuck with Nibblebill config. Even if the current balance is 0 or negative, the dialplan start the call.
Someone would have some examples of config where this behaviour is avoided? Thank you!
Regards,
Igor.
*De :*igor.potjevlesch@gmail.com [mailto:igor.potjevlesch@gmail.com] *Envoyé :* mercredi 10 janvier 2018 15:49 *À :* 'Madovsky' <infos@madovsky.org> *Objet :* RE: [Freeswitch-users] Use Nibblebill with PostgreSQL
This is the log: Action log(INFO ${nibble_balance} is equal or lower than 0)
With or without "set nibble_balance". So I guess that this variable is undefined.
*De :*igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> [mailto:igor.potjevlesch@gmail.com] *Envoyé :* mercredi 10 janvier 2018 15:39 *À :* 'Madovsky' <infos@madovsky.org <mailto:infos@madovsky.org>> *Objet :* RE: [Freeswitch-users] Use Nibblebill with PostgreSQL
I don't understand what is supposed to do the SQL request? I think that, indeed, nibble_balance is not set at the moment of the condition.
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* mardi 9 janvier 2018 21:24 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
you should remove
<action application="set" data="nibble_balance" inline="true"/>
since when you populate nibble_account it makes automatically the SQL request and populate nibble_balance. then don't forget to put all nibble variables on the bridge like {nibble_account=${nibble_account},etc.}sofia/xxx
On 1/9/2018 8:14 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
I didn't. What does it mean "inline" in that case?
I tried like this and add "inline" on all settings. So, now the dialplan looks like this:
<action application="set" data="nibble_account=1" inline="true"/>
<action application="set" data="nibble_rate=1" inline="true"/>
<action application="set" data="nibble_minimum=1" inline="true"/>
<action application="set" data="nibble_rounding=2" inline="true"/>
<action application="set" data="nibble_balance" inline="true"/>
<action application="nibblebill" data="heartbeat 1"/>
<condition break="on-true" field="${cond(${nibble_balance} <= 0 ? YES : NO)}" expression="^YES$">
<action application="log" data="INFO ${nibble_balance} is equal or lower than 0"/>
</condition>
<action application="bridge" data="{nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/outbound/0$1"/>
The logs are showing the following outputs and the call start:
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_account=1) INLINE
8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_account=1)
8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_account]=[1]
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_rate=1) INLINE
8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_rate=1)
8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_rate]=[1]
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_minimum=1) INLINE
8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_minimum=1)
8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_minimum]=[1]
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_rounding=2) INLINE
8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_rounding=2)
8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_rounding]=[2]
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_balance) INLINE
8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_balance)
8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_balance]=[UNDEF]
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action nibblebill(heartbeat 1)
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action bridge({nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=}sofia/gateway/out/0123456789)
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action hangup(hangup_cause)
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* lundi 8 janvier 2018 19:52 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
did you set nibble balance inline="true" before the condition?
also check with log just after you set the var to be sure the SQL return a value
On 1/8/2018 10:24 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
I basically tried this:
<condition break="on-true" field="${cond(${nibble_balance} <= 0 ? YES : NO)}" expression="^YES$">
<action application="log" data="INFO ${nibble_balance} is equal or lower than 0"/>
</condition>
But I didn't see anything in the logs, the call begin to start.
Regards,
Igor
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* vendredi 5 janvier 2018 14:44 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
Yes in a nested condition for ex.
this method is more robust that trust nibblebill to do all the job
On 1/5/2018 5:33 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
It means that I can test ${nibble_balance} before right?
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* jeudi 4 janvier 2018 20:31 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
you should make a nested condition before the bridge
and if the balance not good transfer the call to hangup or something else
On 1/4/2018 8:03 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
I uncommented this in the config file of nibblebill:
<param name="custom_sql_lookup" value="SELECT euros AS nibble_balance FROM solde WHERE customer_id='${nibble_account}'"/>
The request is working fine according to the logs, but the call is still placed with the logs:
2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:422 Doing lookup query
[SELECT euros AS nibble_balance FROM solde WHERE customer_id='1']
2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:430 Retrieved current balance for account 1 (balance = -0.040000)
31fe25c6-f168-11e7-a065-b10720ff818b 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:523 Comparing -0.040000 to hangup balance of 1.000000, taking into account minimum charge of 1.000000
31fe25c6-f168-11e7-a065-b10720ff818b 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:526 Balance of -0.040000 fell below allowed amount of 1.000000! (Account 1)
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* jeudi 4 janvier 2018 16:37 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
add an sql request into nibblebill and link it to nibble_balance variables inline in diaplan
On 1/4/2018 7:35 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
Yes, why not, but I don't find how to check the balance before a bridge.
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* jeudi 4 janvier 2018 16:29 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
it starts because you don't have any user linked to your nibble_account
so the only way to not start the call is to create a condition with the nibble balance before
the bridge
On 1/4/2018 7:22 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
I did this:
dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_account=1)
dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1 /+4425482090@A.B.C.D <mailto:/+4425482090@A.B.C.D> Action set(nibble_rate=1)
dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_minimum=1)
dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_rounding=2)
dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action nibblebill(heartbeat 1)
dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action bridge({nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=}sofia/gateway/out_1/0123456789)
[…]
2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:430 Retrieved current balance for account 1 (balance = 0.000000)
dca7b05c-f161-11e7-9f9a-b10720ff818b 2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:523 Comparing 0.000000 to hangup balance of 1.000000, taking into account minimum charge of 1.000000
dca7b05c-f161-11e7-9f9a-b10720ff818b 2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:526 Balance of 0.000000 fell below allowed amount of 1.000000! (Account 1)
But the call still starts.
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* jeudi 4 janvier 2018 16:09 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
the nibblebill variables must be on the bridge like
<action application="bridge" data="{nibble_account=1,nibble_rate=1,etc....absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/out_01/0$1"/>
do not use "export" since I noticed some strange behavior with it. I don't know how nibblebill behaves without a nibble_account linked to a user account, so I cannot help for this case
On 1/4/2018 7:06 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
I don't have a registered user. It's a peer trusted by his IP address.
During the call the credit is updated every seconds but even without credit, the call start and stop immediately.
Yes I know. I will switch to more reasonable value after my tests.
What do you mean by "export all nibblebill variables to the bridge"?
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* jeudi 4 janvier 2018 15:52 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
> <action application="set" data="nibble_account=1"/>
is 1 a valid nibble_account of a registered user?
> <action application="nibblebill" data="check"/>
you dont' need to check, as nibblebill automatically check the balance
if the nibble_account is linked to a registered user
> <action application="nibblebill" data="heartbeat 1"/>
be aware that heartbeat to 1 means a request to your DB every second
about your issue you should export all nibblebill variables to the bridge too
On 1/4/2018 6:46 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
That's the case:
<condition break="on-true" expression="^\+44([1-9][0-9]{8})$" field="destination_number">
<action application="set" data="nibble_account=1"/>
<action application="nibblebill" data="check"/>
<action application="set" data="nibble_rate=1"/>
<action application="set" data="nibble_minimum=1"/>
<action application="set" data="nibble_rounding=2"/>
<action application="nibblebill" data="heartbeat 1"/>
<action application="bridge" data="{absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/out_01/0$1"/>
<action application="hangup" data="hangup_cause"/>
</condition>
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* jeudi 4 janvier 2018 12:41 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
you must check or set nibble_account before the call
On 1/4/2018 3:35 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
Hello,
Finally the billing works good. Would it be possible to setup the rates in db? I don't find example or documentation related to this.
Also, I don't understand why the call is allowed for bridging whereas the balance is 0 or negative?
Regards,
Igor.
*De :*igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> [mailto:igor.potjevlesch@gmail.com] *Envoyé :* jeudi 4 janvier 2018 10:19 *À :* 'FreeSWITCH Users Help' <freeswitch-users@lists.freeswitch.org> <mailto:freeswitch-users@lists.freeswitch.org> *Objet :* RE: [Freeswitch-users] Use Nibblebill with PostgreSQL
Hello,
Thank you!
Both db_dsn and odbc-dsn work. db-dsn fails.
I keep the version with odbc-dsn because in that case I don't have the warning about deprecated function for versions earlier than 1.4.2 even if I run 1.6.
What is the best according to you? db_dsn or odbc-dsn?
I have additional questions related to nibble:
1. After hanging up the call, I see in the logs the good value: "mod_nibblebill.c:590 Billing $0.000234" but some line after there is another update: "mod_nibblebill.c:622 Rounding to precision 1.000000, total 1.000000 (0.999793 excess)". So the call is billed 1 instead of 0.000234. 2. Is it possible to setup in the db scheme different prefixes and their rate? Instead of putting them raw in the dialplan or any other config file?
Thank you in advance for your clarification.
Regards,
Igor.
*De :*FreeSWITCH-users [mailto:freeswitch-users-bounces@lists.freeswitch.org] *De la part de* Madovsky *Envoyé :* mercredi 3 janvier 2018 22:18 *À :* freeswitch-users@lists.freeswitch.org <mailto:freeswitch-users@lists.freeswitch.org> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
If you compiled FS with --enable-core-odbc-support so you can use
<param name="odbc-dsn" value="pgsql://hostaddr=xx.xx.xx.xx port=xxxx dbname=xxx user=xxx password='xxxx' options='-c client_min_messages=NOTICE' application_name='freeswitch'" />
you must set odbc.ini
On 1/3/2018 1:02 PM, Geoff Mina wrote:
I think the param is db-dsn. Not the underscore version.
On Jan 3, 2018, at 12:59 PM, Sergey Safarov <s.safarov@gmail.com <mailto:s.safarov@gmail.com>> wrote:
I used connection string
<param name="db_dsn" value="pgsql://hostaddr=127.0.0.1 dbname=******* user=******* password=*******"/>
Sergey
ср, 3 янв. 2018 г. в 22:06, <igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com>>:
Hello !
I try to connect Nibblebill directly to PostgreSQL but it still fails.
I follow the documentation and setup the param like this: <param name="odbc_dsn" value="pgsql://A.B.C.D dbname=prepaid user=prepaid password=<hidden>"/>
When I hangup a call, the logs report the following: 52c8b77c-f0b8-11e7-8d19-5566a3fb77f6 2018-01-03 20:00:19.037333 [CRIT] mod_nibblebill.c:604 Failed to log to database!
Any idea on how to proceed with FS 1.6? Thank you!
Regards,
Igor.
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com
Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com
Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
consulting@freeswitch.org <mailto:consulting@freeswitch.org>
http://www.freeswitchsolutions.com
Official FreeSWITCH Sites
http://confluence.freeswitch.org
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org>
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
consulting@freeswitch.org <mailto:consulting@freeswitch.org>
http://www.freeswitchsolutions.com
Official FreeSWITCH Sites
http://confluence.freeswitch.org
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org>
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
Ah ok, I didn't know nibble_current_balance. So with something like that should work, but unfortunately not: <action application="set" data="nibble_account=98"/> <action application="set" data="nibble_rate=0.0115"/> <action application="set" data="nibble_minimum=1"/> <action application="set" data="nibble_rounding=2"/> <action application="set" data="heartbeat 1"/> <action application="set" data="nibble_current_balance" inline="true"/> <condition break="on-true" field="${cond(${nibble_current_balance} <= 0 ? YES : NO)}" expression="^YES$"> <action application="hangup" data="hangup_cause"/> </condition> The call is processed whereas balance in DB is equal to 0. De : FreeSWITCH-users [mailto:freeswitch-users-bounces@lists.freeswitch.org] De la part de Madovsky Envoyé : lundi 15 janvier 2018 17:59 À : 'FreeSWITCH Users Help' <freeswitch-users@lists.freeswitch.org> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
I don't understand what is supposed to do the SQL request? I think that, indeed, nibble_balance is not set at the moment of the condition.
when you set the nibble account so nibblebill makes the SQL request you set in its config to populate nibble_current_balance, so if you make a condition with nibble_current_balance just after set nibble_account so you should set it inline to make the condition available On 1/15/2018 5:29 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: Hello, I'm still stuck with Nibblebill config. Even if the current balance is 0 or negative, the dialplan start the call. Someone would have some examples of config where this behaviour is avoided? Thank you! Regards, Igor. De : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> [mailto:igor.potjevlesch@gmail.com] Envoyé : mercredi 10 janvier 2018 15:49 À : 'Madovsky' <mailto:infos@madovsky.org> <infos@madovsky.org> Objet : RE: [Freeswitch-users] Use Nibblebill with PostgreSQL This is the log: Action log(INFO ${nibble_balance} is equal or lower than 0) With or without "set nibble_balance". So I guess that this variable is undefined. De : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> [mailto:igor.potjevlesch@gmail.com] Envoyé : mercredi 10 janvier 2018 15:39 À : 'Madovsky' <infos@madovsky.org <mailto:infos@madovsky.org> > Objet : RE: [Freeswitch-users] Use Nibblebill with PostgreSQL I don't understand what is supposed to do the SQL request? I think that, indeed, nibble_balance is not set at the moment of the condition. De : Madovsky [mailto:infos@madovsky.org] Envoyé : mardi 9 janvier 2018 21:24 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL you should remove <action application="set" data="nibble_balance" inline="true"/> since when you populate nibble_account it makes automatically the SQL request and populate nibble_balance. then don't forget to put all nibble variables on the bridge like {nibble_account=${nibble_account},etc.}sofia/xxx On 1/9/2018 8:14 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: I didn't. What does it mean "inline" in that case? I tried like this and add "inline" on all settings. So, now the dialplan looks like this: <action application="set" data="nibble_account=1" inline="true"/> <action application="set" data="nibble_rate=1" inline="true"/> <action application="set" data="nibble_minimum=1" inline="true"/> <action application="set" data="nibble_rounding=2" inline="true"/> <action application="set" data="nibble_balance" inline="true"/> <action application="nibblebill" data="heartbeat 1"/> <condition break="on-true" field="${cond(${nibble_balance} <= 0 ? YES : NO)}" expression="^YES$"> <action application="log" data="INFO ${nibble_balance} is equal or lower than 0"/> </condition> <action application="bridge" data="{nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/outbound/0$1"/> The logs are showing the following outputs and the call start: 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_account=1) INLINE 8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_account=1) 8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_account]=[1] 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_rate=1) INLINE 8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_rate=1) 8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_rate]=[1] 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_minimum=1) INLINE 8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_minimum=1) 8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_minimum]=[1] 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_rounding=2) INLINE 8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_rounding=2) 8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_rounding]=[2] 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_balance) INLINE 8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_balance) 8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_balance]=[UNDEF] 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action nibblebill(heartbeat 1) 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action bridge({nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=}sofia/gateway/out/0123456789) 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action hangup(hangup_cause) De : Madovsky [mailto:infos@madovsky.org] Envoyé : lundi 8 janvier 2018 19:52 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL did you set nibble balance inline="true" before the condition? also check with log just after you set the var to be sure the SQL return a value On 1/8/2018 10:24 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: I basically tried this: <condition break="on-true" field="${cond(${nibble_balance} <= 0 ? YES : NO)}" expression="^YES$"> <action application="log" data="INFO ${nibble_balance} is equal or lower than 0"/> </condition> But I didn't see anything in the logs, the call begin to start. Regards, Igor De : Madovsky [mailto:infos@madovsky.org] Envoyé : vendredi 5 janvier 2018 14:44 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL Yes in a nested condition for ex. this method is more robust that trust nibblebill to do all the job On 1/5/2018 5:33 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: It means that I can test ${nibble_balance} before right? De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 20:31 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL you should make a nested condition before the bridge and if the balance not good transfer the call to hangup or something else On 1/4/2018 8:03 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: I uncommented this in the config file of nibblebill: <param name="custom_sql_lookup" value="SELECT euros AS nibble_balance FROM solde WHERE customer_id='${nibble_account}'"/> The request is working fine according to the logs, but the call is still placed with the logs: 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:422 Doing lookup query [SELECT euros AS nibble_balance FROM solde WHERE customer_id='1'] 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:430 Retrieved current balance for account 1 (balance = -0.040000) 31fe25c6-f168-11e7-a065-b10720ff818b 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:523 Comparing -0.040000 to hangup balance of 1.000000, taking into account minimum charge of 1.000000 31fe25c6-f168-11e7-a065-b10720ff818b 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:526 Balance of -0.040000 fell below allowed amount of 1.000000! (Account 1) De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 16:37 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL add an sql request into nibblebill and link it to nibble_balance variables inline in diaplan On 1/4/2018 7:35 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: Yes, why not, but I don't find how to check the balance before a bridge. De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 16:29 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL it starts because you don't have any user linked to your nibble_account so the only way to not start the call is to create a condition with the nibble balance before the bridge On 1/4/2018 7:22 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: I did this: dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_account=1) dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1 /+4425482090@A.B.C.D <mailto:/+4425482090@A.B.C.D> Action set(nibble_rate=1) dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_minimum=1) dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_rounding=2) dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action nibblebill(heartbeat 1) dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action bridge({nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=}sofia/gateway/out_1/0123456789) […] 2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:430 Retrieved current balance for account 1 (balance = 0.000000) dca7b05c-f161-11e7-9f9a-b10720ff818b 2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:523 Comparing 0.000000 to hangup balance of 1.000000, taking into account minimum charge of 1.000000 dca7b05c-f161-11e7-9f9a-b10720ff818b 2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:526 Balance of 0.000000 fell below allowed amount of 1.000000! (Account 1) But the call still starts. De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 16:09 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL the nibblebill variables must be on the bridge like <action application="bridge" data="{nibble_account=1,nibble_rate=1,etc....absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/out_01/0$1"/> do not use "export" since I noticed some strange behavior with it. I don't know how nibblebill behaves without a nibble_account linked to a user account, so I cannot help for this case On 1/4/2018 7:06 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: I don't have a registered user. It's a peer trusted by his IP address. During the call the credit is updated every seconds but even without credit, the call start and stop immediately. Yes I know. I will switch to more reasonable value after my tests. What do you mean by "export all nibblebill variables to the bridge"? De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 15:52 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
<action application="set" data="nibble_account=1"/>
is 1 a valid nibble_account of a registered user?
<action application="nibblebill" data="check"/>
you dont' need to check, as nibblebill automatically check the balance if the nibble_account is linked to a registered user
<action application="nibblebill" data="heartbeat 1"/>
be aware that heartbeat to 1 means a request to your DB every second about your issue you should export all nibblebill variables to the bridge too On 1/4/2018 6:46 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: That's the case: <condition break="on-true" expression="^\+44([1-9][0-9]{8})$" field="destination_number"> <action application="set" data="nibble_account=1"/> <action application="nibblebill" data="check"/> <action application="set" data="nibble_rate=1"/> <action application="set" data="nibble_minimum=1"/> <action application="set" data="nibble_rounding=2"/> <action application="nibblebill" data="heartbeat 1"/> <action application="bridge" data="{absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/out_01/0$1"/> <action application="hangup" data="hangup_cause"/> </condition> De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 12:41 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL you must check or set nibble_account before the call On 1/4/2018 3:35 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: Hello, Finally the billing works good. Would it be possible to setup the rates in db? I don't find example or documentation related to this. Also, I don't understand why the call is allowed for bridging whereas the balance is 0 or negative? Regards, Igor. De : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> [mailto:igor.potjevlesch@gmail.com] Envoyé : jeudi 4 janvier 2018 10:19 À : 'FreeSWITCH Users Help' <mailto:freeswitch-users@lists.freeswitch.org> <freeswitch-users@lists.freeswitch.org> Objet : RE: [Freeswitch-users] Use Nibblebill with PostgreSQL Hello, Thank you! Both db_dsn and odbc-dsn work. db-dsn fails. I keep the version with odbc-dsn because in that case I don't have the warning about deprecated function for versions earlier than 1.4.2 even if I run 1.6. What is the best according to you? db_dsn or odbc-dsn? I have additional questions related to nibble: 1. After hanging up the call, I see in the logs the good value: "mod_nibblebill.c:590 Billing $0.000234" but some line after there is another update: "mod_nibblebill.c:622 Rounding to precision 1.000000, total 1.000000 (0.999793 excess)". So the call is billed 1 instead of 0.000234. 2. Is it possible to setup in the db scheme different prefixes and their rate? Instead of putting them raw in the dialplan or any other config file? Thank you in advance for your clarification. Regards, Igor. De : FreeSWITCH-users [mailto:freeswitch-users-bounces@lists.freeswitch.org] De la part de Madovsky Envoyé : mercredi 3 janvier 2018 22:18 À : freeswitch-users@lists.freeswitch.org <mailto:freeswitch-users@lists.freeswitch.org> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL If you compiled FS with --enable-core-odbc-support so you can use <param name="odbc-dsn" value="pgsql://hostaddr=xx.xx.xx.xx port=xxxx dbname=xxx user=xxx password='xxxx' options='-c client_min_messages=NOTICE' application_name='freeswitch'" /> you must set odbc.ini On 1/3/2018 1:02 PM, Geoff Mina wrote: I think the param is db-dsn. Not the underscore version. On Jan 3, 2018, at 12:59 PM, Sergey Safarov <s.safarov@gmail.com <mailto:s.safarov@gmail.com> > wrote: I used connection string <param name="db_dsn" value="pgsql://hostaddr=127.0.0.1 dbname=******* user=******* password=*******"/> Sergey ср, 3 янв. 2018 г. в 22:06, <igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> >: Hello ! I try to connect Nibblebill directly to PostgreSQL but it still fails. I follow the documentation and setup the param like this: <param name="odbc_dsn" value="pgsql://A.B.C.D dbname=prepaid user=prepaid password=<hidden>"/> When I hangup a call, the logs report the following: 52c8b77c-f0b8-11e7-8d19-5566a3fb77f6 2018-01-03 20:00:19.037333 [CRIT] mod_nibblebill.c:604 Failed to log to database! Any idea on how to proceed with FS 1.6? Thank you! Regards, Igor. _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
I'm wondering if there's not something wrong here: 2018-01-15 18:56:53.560265 [DEBUG] mod_nibblebill.c:430 Retrieved current balance for account 98 (balance = 0.000000) 782f5610-fa1d-11e7-933a-47832fb85dfe 2018-01-15 18:56:53.560265 [DEBUG] mod_nibblebill.c:523 Comparing 0.000000 to hangup balance of 1.000000, taking into account minimum charge of 1.000000 782f5610-fa1d-11e7-933a-47832fb85dfe 2018-01-15 18:56:53.560265 [DEBUG] mod_nibblebill.c:526 Balance of 0.000000 fell below allowed amount of 1.000000! (Account 98) 782bbabe-fa1d-11e7-9318-47832fb85dfe 2018-01-15 18:56:53.560265 [INFO] mod_dialplan_xml.c:637 Processing +123456789 ->hangup in context test According to the source code, the call is transferred to default "nobal_amt" which is "hangup". So the call is supposed to be stopped once this log is printed. Isn't it? De : igor.potjevlesch@gmail.com [mailto:igor.potjevlesch@gmail.com] Envoyé : lundi 15 janvier 2018 18:51 À : 'FreeSWITCH Users Help' <freeswitch-users@lists.freeswitch.org> Objet : RE: [Freeswitch-users] Use Nibblebill with PostgreSQL Ah ok, I didn't know nibble_current_balance. So with something like that should work, but unfortunately not: <action application="set" data="nibble_account=98"/> <action application="set" data="nibble_rate=0.0115"/> <action application="set" data="nibble_minimum=1"/> <action application="set" data="nibble_rounding=2"/> <action application="set" data="heartbeat 1"/> <action application="set" data="nibble_current_balance" inline="true"/> <condition break="on-true" field="${cond(${nibble_current_balance} <= 0 ? YES : NO)}" expression="^YES$"> <action application="hangup" data="hangup_cause"/> </condition> The call is processed whereas balance in DB is equal to 0. De : FreeSWITCH-users [mailto:freeswitch-users-bounces@lists.freeswitch.org] De la part de Madovsky Envoyé : lundi 15 janvier 2018 17:59 À : 'FreeSWITCH Users Help' <freeswitch-users@lists.freeswitch.org <mailto:freeswitch-users@lists.freeswitch.org> > Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
I don't understand what is supposed to do the SQL request? I think that, indeed, nibble_balance is not set at the moment of the condition.
when you set the nibble account so nibblebill makes the SQL request you set in its config to populate nibble_current_balance, so if you make a condition with nibble_current_balance just after set nibble_account so you should set it inline to make the condition available On 1/15/2018 5:29 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: Hello, I'm still stuck with Nibblebill config. Even if the current balance is 0 or negative, the dialplan start the call. Someone would have some examples of config where this behaviour is avoided? Thank you! Regards, Igor. De : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> [mailto:igor.potjevlesch@gmail.com] Envoyé : mercredi 10 janvier 2018 15:49 À : 'Madovsky' <mailto:infos@madovsky.org> <infos@madovsky.org> Objet : RE: [Freeswitch-users] Use Nibblebill with PostgreSQL This is the log: Action log(INFO ${nibble_balance} is equal or lower than 0) With or without "set nibble_balance". So I guess that this variable is undefined. De : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> [mailto:igor.potjevlesch@gmail.com] Envoyé : mercredi 10 janvier 2018 15:39 À : 'Madovsky' <infos@madovsky.org <mailto:infos@madovsky.org> > Objet : RE: [Freeswitch-users] Use Nibblebill with PostgreSQL I don't understand what is supposed to do the SQL request? I think that, indeed, nibble_balance is not set at the moment of the condition. De : Madovsky [mailto:infos@madovsky.org] Envoyé : mardi 9 janvier 2018 21:24 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL you should remove <action application="set" data="nibble_balance" inline="true"/> since when you populate nibble_account it makes automatically the SQL request and populate nibble_balance. then don't forget to put all nibble variables on the bridge like {nibble_account=${nibble_account},etc.}sofia/xxx On 1/9/2018 8:14 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: I didn't. What does it mean "inline" in that case? I tried like this and add "inline" on all settings. So, now the dialplan looks like this: <action application="set" data="nibble_account=1" inline="true"/> <action application="set" data="nibble_rate=1" inline="true"/> <action application="set" data="nibble_minimum=1" inline="true"/> <action application="set" data="nibble_rounding=2" inline="true"/> <action application="set" data="nibble_balance" inline="true"/> <action application="nibblebill" data="heartbeat 1"/> <condition break="on-true" field="${cond(${nibble_balance} <= 0 ? YES : NO)}" expression="^YES$"> <action application="log" data="INFO ${nibble_balance} is equal or lower than 0"/> </condition> <action application="bridge" data="{nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/outbound/0$1"/> The logs are showing the following outputs and the call start: 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D Action set(nibble_account=1) INLINE 8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_account=1) 8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_account]=[1] 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_rate=1) INLINE 8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_rate=1) 8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_rate]=[1] 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_minimum=1) INLINE 8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_minimum=1) 8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_minimum]=[1] 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_rounding=2) INLINE 8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_rounding=2) 8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_rounding]=[2] 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_balance) INLINE 8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_balance) 8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_balance]=[UNDEF] 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action nibblebill(heartbeat 1) 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action bridge({nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=}sofia/gateway/out/0123456789) 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action hangup(hangup_cause) De : Madovsky [mailto:infos@madovsky.org] Envoyé : lundi 8 janvier 2018 19:52 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL did you set nibble balance inline="true" before the condition? also check with log just after you set the var to be sure the SQL return a value On 1/8/2018 10:24 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: I basically tried this: <condition break="on-true" field="${cond(${nibble_balance} <= 0 ? YES : NO)}" expression="^YES$"> <action application="log" data="INFO ${nibble_balance} is equal or lower than 0"/> </condition> But I didn't see anything in the logs, the call begin to start. Regards, Igor De : Madovsky [mailto:infos@madovsky.org] Envoyé : vendredi 5 janvier 2018 14:44 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL Yes in a nested condition for ex. this method is more robust that trust nibblebill to do all the job On 1/5/2018 5:33 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: It means that I can test ${nibble_balance} before right? De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 20:31 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL you should make a nested condition before the bridge and if the balance not good transfer the call to hangup or something else On 1/4/2018 8:03 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: I uncommented this in the config file of nibblebill: <param name="custom_sql_lookup" value="SELECT euros AS nibble_balance FROM solde WHERE customer_id='${nibble_account}'"/> The request is working fine according to the logs, but the call is still placed with the logs: 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:422 Doing lookup query [SELECT euros AS nibble_balance FROM solde WHERE customer_id='1'] 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:430 Retrieved current balance for account 1 (balance = -0.040000) 31fe25c6-f168-11e7-a065-b10720ff818b 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:523 Comparing -0.040000 to hangup balance of 1.000000, taking into account minimum charge of 1.000000 31fe25c6-f168-11e7-a065-b10720ff818b 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:526 Balance of -0.040000 fell below allowed amount of 1.000000! (Account 1) De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 16:37 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL add an sql request into nibblebill and link it to nibble_balance variables inline in diaplan On 1/4/2018 7:35 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: Yes, why not, but I don't find how to check the balance before a bridge. De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 16:29 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL it starts because you don't have any user linked to your nibble_account so the only way to not start the call is to create a condition with the nibble balance before the bridge On 1/4/2018 7:22 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: I did this: dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_account=1) dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1 /+4425482090@A.B.C.D <mailto:/+4425482090@A.B.C.D> Action set(nibble_rate=1) dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_minimum=1) dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_rounding=2) dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action nibblebill(heartbeat 1) dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action bridge({nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=}sofia/gateway/out_1/0123456789) […] 2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:430 Retrieved current balance for account 1 (balance = 0.000000) dca7b05c-f161-11e7-9f9a-b10720ff818b 2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:523 Comparing 0.000000 to hangup balance of 1.000000, taking into account minimum charge of 1.000000 dca7b05c-f161-11e7-9f9a-b10720ff818b 2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:526 Balance of 0.000000 fell below allowed amount of 1.000000! (Account 1) But the call still starts. De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 16:09 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL the nibblebill variables must be on the bridge like <action application="bridge" data="{nibble_account=1,nibble_rate=1,etc....absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/out_01/0$1"/> do not use "export" since I noticed some strange behavior with it. I don't know how nibblebill behaves without a nibble_account linked to a user account, so I cannot help for this case On 1/4/2018 7:06 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: I don't have a registered user. It's a peer trusted by his IP address. During the call the credit is updated every seconds but even without credit, the call start and stop immediately. Yes I know. I will switch to more reasonable value after my tests. What do you mean by "export all nibblebill variables to the bridge"? De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 15:52 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
<action application="set" data="nibble_account=1"/>
is 1 a valid nibble_account of a registered user?
<action application="nibblebill" data="check"/>
you dont' need to check, as nibblebill automatically check the balance if the nibble_account is linked to a registered user
<action application="nibblebill" data="heartbeat 1"/>
be aware that heartbeat to 1 means a request to your DB every second about your issue you should export all nibblebill variables to the bridge too On 1/4/2018 6:46 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: That's the case: <condition break="on-true" expression="^\+44([1-9][0-9]{8})$" field="destination_number"> <action application="set" data="nibble_account=1"/> <action application="nibblebill" data="check"/> <action application="set" data="nibble_rate=1"/> <action application="set" data="nibble_minimum=1"/> <action application="set" data="nibble_rounding=2"/> <action application="nibblebill" data="heartbeat 1"/> <action application="bridge" data="{absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/out_01/0$1"/> <action application="hangup" data="hangup_cause"/> </condition> De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 12:41 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL you must check or set nibble_account before the call On 1/4/2018 3:35 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: Hello, Finally the billing works good. Would it be possible to setup the rates in db? I don't find example or documentation related to this. Also, I don't understand why the call is allowed for bridging whereas the balance is 0 or negative? Regards, Igor. De : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> [mailto:igor.potjevlesch@gmail.com] Envoyé : jeudi 4 janvier 2018 10:19 À : 'FreeSWITCH Users Help' <mailto:freeswitch-users@lists.freeswitch.org> <freeswitch-users@lists.freeswitch.org> Objet : RE: [Freeswitch-users] Use Nibblebill with PostgreSQL Hello, Thank you! Both db_dsn and odbc-dsn work. db-dsn fails. I keep the version with odbc-dsn because in that case I don't have the warning about deprecated function for versions earlier than 1.4.2 even if I run 1.6. What is the best according to you? db_dsn or odbc-dsn? I have additional questions related to nibble: 1. After hanging up the call, I see in the logs the good value: "mod_nibblebill.c:590 Billing $0.000234" but some line after there is another update: "mod_nibblebill.c:622 Rounding to precision 1.000000, total 1.000000 (0.999793 excess)". So the call is billed 1 instead of 0.000234. 2. Is it possible to setup in the db scheme different prefixes and their rate? Instead of putting them raw in the dialplan or any other config file? Thank you in advance for your clarification. Regards, Igor. De : FreeSWITCH-users [mailto:freeswitch-users-bounces@lists.freeswitch.org] De la part de Madovsky Envoyé : mercredi 3 janvier 2018 22:18 À : freeswitch-users@lists.freeswitch.org <mailto:freeswitch-users@lists.freeswitch.org> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL If you compiled FS with --enable-core-odbc-support so you can use <param name="odbc-dsn" value="pgsql://hostaddr=xx.xx.xx.xx port=xxxx dbname=xxx user=xxx password='xxxx' options='-c client_min_messages=NOTICE' application_name='freeswitch'" /> you must set odbc.ini On 1/3/2018 1:02 PM, Geoff Mina wrote: I think the param is db-dsn. Not the underscore version. On Jan 3, 2018, at 12:59 PM, Sergey Safarov <s.safarov@gmail.com <mailto:s.safarov@gmail.com> > wrote: I used connection string <param name="db_dsn" value="pgsql://hostaddr=127.0.0.1 dbname=******* user=******* password=*******"/> Sergey ср, 3 янв. 2018 г. в 22:06, <igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> >: Hello ! I try to connect Nibblebill directly to PostgreSQL but it still fails. I follow the documentation and setup the param like this: <param name="odbc_dsn" value="pgsql://A.B.C.D dbname=prepaid user=prepaid password=<hidden>"/> When I hangup a call, the logs report the following: 52c8b77c-f0b8-11e7-8d19-5566a3fb77f6 2018-01-03 20:00:19.037333 [CRIT] mod_nibblebill.c:604 Failed to log to database! Any idea on how to proceed with FS 1.6? Thank you! Regards, Igor. _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
This is it. I didn't have extension called "hangup". So now, I setup "hangup" extension with only one action "application=hangup". So now, the call is rejected if there is no credit. Thank you for your time and patience! I'd also like to setup a dynamic nibble_rate value based on DB lookup and called prefix. Is it something that I can do with nibble or other module in FS? De : igor.potjevlesch@gmail.com [mailto:igor.potjevlesch@gmail.com] Envoyé : lundi 15 janvier 2018 19:04 À : 'FreeSWITCH Users Help' <freeswitch-users@lists.freeswitch.org> Objet : RE: [Freeswitch-users] Use Nibblebill with PostgreSQL I'm wondering if there's not something wrong here: 2018-01-15 18:56:53.560265 [DEBUG] mod_nibblebill.c:430 Retrieved current balance for account 98 (balance = 0.000000) 782f5610-fa1d-11e7-933a-47832fb85dfe 2018-01-15 18:56:53.560265 [DEBUG] mod_nibblebill.c:523 Comparing 0.000000 to hangup balance of 1.000000, taking into account minimum charge of 1.000000 782f5610-fa1d-11e7-933a-47832fb85dfe 2018-01-15 18:56:53.560265 [DEBUG] mod_nibblebill.c:526 Balance of 0.000000 fell below allowed amount of 1.000000! (Account 98) 782bbabe-fa1d-11e7-9318-47832fb85dfe 2018-01-15 18:56:53.560265 [INFO] mod_dialplan_xml.c:637 Processing +123456789 ->hangup in context test According to the source code, the call is transferred to default "nobal_amt" which is "hangup". So the call is supposed to be stopped once this log is printed. Isn't it? De : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> [mailto:igor.potjevlesch@gmail.com] Envoyé : lundi 15 janvier 2018 18:51 À : 'FreeSWITCH Users Help' <freeswitch-users@lists.freeswitch.org <mailto:freeswitch-users@lists.freeswitch.org> > Objet : RE: [Freeswitch-users] Use Nibblebill with PostgreSQL Ah ok, I didn't know nibble_current_balance. So with something like that should work, but unfortunately not: <action application="set" data="nibble_account=98"/> <action application="set" data="nibble_rate=0.0115"/> <action application="set" data="nibble_minimum=1"/> <action application="set" data="nibble_rounding=2"/> <action application="set" data="heartbeat 1"/> <action application="set" data="nibble_current_balance" inline="true"/> <condition break="on-true" field="${cond(${nibble_current_balance} <= 0 ? YES : NO)}" expression="^YES$"> <action application="hangup" data="hangup_cause"/> </condition> The call is processed whereas balance in DB is equal to 0. De : FreeSWITCH-users [mailto:freeswitch-users-bounces@lists.freeswitch.org] De la part de Madovsky Envoyé : lundi 15 janvier 2018 17:59 À : 'FreeSWITCH Users Help' <freeswitch-users@lists.freeswitch.org <mailto:freeswitch-users@lists.freeswitch.org> > Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
I don't understand what is supposed to do the SQL request? I think that, indeed, nibble_balance is not set at the moment of the condition.
when you set the nibble account so nibblebill makes the SQL request you set in its config to populate nibble_current_balance, so if you make a condition with nibble_current_balance just after set nibble_account so you should set it inline to make the condition available On 1/15/2018 5:29 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: Hello, I'm still stuck with Nibblebill config. Even if the current balance is 0 or negative, the dialplan start the call. Someone would have some examples of config where this behaviour is avoided? Thank you! Regards, Igor. De : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> [mailto:igor.potjevlesch@gmail.com] Envoyé : mercredi 10 janvier 2018 15:49 À : 'Madovsky' <mailto:infos@madovsky.org> <infos@madovsky.org> Objet : RE: [Freeswitch-users] Use Nibblebill with PostgreSQL This is the log: Action log(INFO ${nibble_balance} is equal or lower than 0) With or without "set nibble_balance". So I guess that this variable is undefined. De : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> [mailto:igor.potjevlesch@gmail.com] Envoyé : mercredi 10 janvier 2018 15:39 À : 'Madovsky' <infos@madovsky.org <mailto:infos@madovsky.org> > Objet : RE: [Freeswitch-users] Use Nibblebill with PostgreSQL I don't understand what is supposed to do the SQL request? I think that, indeed, nibble_balance is not set at the moment of the condition. De : Madovsky [mailto:infos@madovsky.org] Envoyé : mardi 9 janvier 2018 21:24 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL you should remove <action application="set" data="nibble_balance" inline="true"/> since when you populate nibble_account it makes automatically the SQL request and populate nibble_balance. then don't forget to put all nibble variables on the bridge like {nibble_account=${nibble_account},etc.}sofia/xxx On 1/9/2018 8:14 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: I didn't. What does it mean "inline" in that case? I tried like this and add "inline" on all settings. So, now the dialplan looks like this: <action application="set" data="nibble_account=1" inline="true"/> <action application="set" data="nibble_rate=1" inline="true"/> <action application="set" data="nibble_minimum=1" inline="true"/> <action application="set" data="nibble_rounding=2" inline="true"/> <action application="set" data="nibble_balance" inline="true"/> <action application="nibblebill" data="heartbeat 1"/> <condition break="on-true" field="${cond(${nibble_balance} <= 0 ? YES : NO)}" expression="^YES$"> <action application="log" data="INFO ${nibble_balance} is equal or lower than 0"/> </condition> <action application="bridge" data="{nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/outbound/0$1"/> The logs are showing the following outputs and the call start: 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_account=1) INLINE 8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_account=1) 8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_account]=[1] 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_rate=1) INLINE 8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_rate=1) 8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_rate]=[1] 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_minimum=1) INLINE 8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_minimum=1) 8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_minimum]=[1] 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_rounding=2) INLINE 8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_rounding=2) 8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_rounding]=[2] 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_balance) INLINE 8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_balance) 8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_balance]=[UNDEF] 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action nibblebill(heartbeat 1) 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action bridge({nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=}sofia/gateway/out/0123456789) 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action hangup(hangup_cause) De : Madovsky [mailto:infos@madovsky.org] Envoyé : lundi 8 janvier 2018 19:52 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL did you set nibble balance inline="true" before the condition? also check with log just after you set the var to be sure the SQL return a value On 1/8/2018 10:24 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: I basically tried this: <condition break="on-true" field="${cond(${nibble_balance} <= 0 ? YES : NO)}" expression="^YES$"> <action application="log" data="INFO ${nibble_balance} is equal or lower than 0"/> </condition> But I didn't see anything in the logs, the call begin to start. Regards, Igor De : Madovsky [mailto:infos@madovsky.org] Envoyé : vendredi 5 janvier 2018 14:44 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL Yes in a nested condition for ex. this method is more robust that trust nibblebill to do all the job On 1/5/2018 5:33 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: It means that I can test ${nibble_balance} before right? De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 20:31 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL you should make a nested condition before the bridge and if the balance not good transfer the call to hangup or something else On 1/4/2018 8:03 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: I uncommented this in the config file of nibblebill: <param name="custom_sql_lookup" value="SELECT euros AS nibble_balance FROM solde WHERE customer_id='${nibble_account}'"/> The request is working fine according to the logs, but the call is still placed with the logs: 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:422 Doing lookup query [SELECT euros AS nibble_balance FROM solde WHERE customer_id='1'] 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:430 Retrieved current balance for account 1 (balance = -0.040000) 31fe25c6-f168-11e7-a065-b10720ff818b 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:523 Comparing -0.040000 to hangup balance of 1.000000, taking into account minimum charge of 1.000000 31fe25c6-f168-11e7-a065-b10720ff818b 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:526 Balance of -0.040000 fell below allowed amount of 1.000000! (Account 1) De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 16:37 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL add an sql request into nibblebill and link it to nibble_balance variables inline in diaplan On 1/4/2018 7:35 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: Yes, why not, but I don't find how to check the balance before a bridge. De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 16:29 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL it starts because you don't have any user linked to your nibble_account so the only way to not start the call is to create a condition with the nibble balance before the bridge On 1/4/2018 7:22 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: I did this: dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_account=1) dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1 /+4425482090@A.B.C.D <mailto:/+4425482090@A.B.C.D> Action set(nibble_rate=1) dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_minimum=1) dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_rounding=2) dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action nibblebill(heartbeat 1) dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action bridge({nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=}sofia/gateway/out_1/0123456789) […] 2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:430 Retrieved current balance for account 1 (balance = 0.000000) dca7b05c-f161-11e7-9f9a-b10720ff818b 2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:523 Comparing 0.000000 to hangup balance of 1.000000, taking into account minimum charge of 1.000000 dca7b05c-f161-11e7-9f9a-b10720ff818b 2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:526 Balance of 0.000000 fell below allowed amount of 1.000000! (Account 1) But the call still starts. De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 16:09 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL the nibblebill variables must be on the bridge like <action application="bridge" data="{nibble_account=1,nibble_rate=1,etc....absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/out_01/0$1"/> do not use "export" since I noticed some strange behavior with it. I don't know how nibblebill behaves without a nibble_account linked to a user account, so I cannot help for this case On 1/4/2018 7:06 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: I don't have a registered user. It's a peer trusted by his IP address. During the call the credit is updated every seconds but even without credit, the call start and stop immediately. Yes I know. I will switch to more reasonable value after my tests. What do you mean by "export all nibblebill variables to the bridge"? De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 15:52 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
<action application="set" data="nibble_account=1"/>
is 1 a valid nibble_account of a registered user?
<action application="nibblebill" data="check"/>
you dont' need to check, as nibblebill automatically check the balance if the nibble_account is linked to a registered user
<action application="nibblebill" data="heartbeat 1"/>
be aware that heartbeat to 1 means a request to your DB every second about your issue you should export all nibblebill variables to the bridge too On 1/4/2018 6:46 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: That's the case: <condition break="on-true" expression="^\+44([1-9][0-9]{8})$" field="destination_number"> <action application="set" data="nibble_account=1"/> <action application="nibblebill" data="check"/> <action application="set" data="nibble_rate=1"/> <action application="set" data="nibble_minimum=1"/> <action application="set" data="nibble_rounding=2"/> <action application="nibblebill" data="heartbeat 1"/> <action application="bridge" data="{absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/out_01/0$1"/> <action application="hangup" data="hangup_cause"/> </condition> De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 12:41 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL you must check or set nibble_account before the call On 1/4/2018 3:35 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: Hello, Finally the billing works good. Would it be possible to setup the rates in db? I don't find example or documentation related to this. Also, I don't understand why the call is allowed for bridging whereas the balance is 0 or negative? Regards, Igor. De : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> [mailto:igor.potjevlesch@gmail.com] Envoyé : jeudi 4 janvier 2018 10:19 À : 'FreeSWITCH Users Help' <mailto:freeswitch-users@lists.freeswitch.org> <freeswitch-users@lists.freeswitch.org> Objet : RE: [Freeswitch-users] Use Nibblebill with PostgreSQL Hello, Thank you! Both db_dsn and odbc-dsn work. db-dsn fails. I keep the version with odbc-dsn because in that case I don't have the warning about deprecated function for versions earlier than 1.4.2 even if I run 1.6. What is the best according to you? db_dsn or odbc-dsn? I have additional questions related to nibble: 1. After hanging up the call, I see in the logs the good value: "mod_nibblebill.c:590 Billing $0.000234" but some line after there is another update: "mod_nibblebill.c:622 Rounding to precision 1.000000, total 1.000000 (0.999793 excess)". So the call is billed 1 instead of 0.000234. 2. Is it possible to setup in the db scheme different prefixes and their rate? Instead of putting them raw in the dialplan or any other config file? Thank you in advance for your clarification. Regards, Igor. De : FreeSWITCH-users [mailto:freeswitch-users-bounces@lists.freeswitch.org] De la part de Madovsky Envoyé : mercredi 3 janvier 2018 22:18 À : freeswitch-users@lists.freeswitch.org <mailto:freeswitch-users@lists.freeswitch.org> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL If you compiled FS with --enable-core-odbc-support so you can use <param name="odbc-dsn" value="pgsql://hostaddr=xx.xx.xx.xx port=xxxx dbname=xxx user=xxx password='xxxx' options='-c client_min_messages=NOTICE' application_name='freeswitch'" /> you must set odbc.ini On 1/3/2018 1:02 PM, Geoff Mina wrote: I think the param is db-dsn. Not the underscore version. On Jan 3, 2018, at 12:59 PM, Sergey Safarov <s.safarov@gmail.com <mailto:s.safarov@gmail.com> > wrote: I used connection string <param name="db_dsn" value="pgsql://hostaddr=127.0.0.1 dbname=******* user=******* password=*******"/> Sergey ср, 3 янв. 2018 г. в 22:06, <igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> >: Hello ! I try to connect Nibblebill directly to PostgreSQL but it still fails. I follow the documentation and setup the param like this: <param name="odbc_dsn" value="pgsql://A.B.C.D dbname=prepaid user=prepaid password=<hidden>"/> When I hangup a call, the logs report the following: 52c8b77c-f0b8-11e7-8d19-5566a3fb77f6 2018-01-03 20:00:19.037333 [CRIT] mod_nibblebill.c:604 Failed to log to database! Any idea on how to proceed with FS 1.6? Thank you! Regards, Igor. _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
That could be done with dynamic dial plan. mod_xml_curl is what i typically use, but there are other options too.
On Jan 15, 2018, at 1:14 PM, igor.potjevlesch@gmail.com wrote:
This is it. I didn't have extension called "hangup". So now, I setup "hangup" extension with only one action "application=hangup". So now, the call is rejected if there is no credit.
Thank you for your time and patience!
I'd also like to setup a dynamic nibble_rate value based on DB lookup and called prefix. Is it something that I can do with nibble or other module in FS?
yes, but as your call is not bridged hangup has no effect. so it's better to redirect to another context and/or extension answering the call with an ivr saying "your credit is too low blablabla" then hangup On 1/15/2018 10:03 AM, igor.potjevlesch@gmail.com wrote:
I'm wondering if there's not something wrong here:
2018-01-15 18:56:53.560265 [DEBUG] mod_nibblebill.c:430 Retrieved current balance for account 98 (balance = 0.000000)
782f5610-fa1d-11e7-933a-47832fb85dfe 2018-01-15 18:56:53.560265 [DEBUG] mod_nibblebill.c:523 Comparing 0.000000 to hangup balance of 1.000000, taking into account minimum charge of 1.000000
782f5610-fa1d-11e7-933a-47832fb85dfe 2018-01-15 18:56:53.560265 [DEBUG] mod_nibblebill.c:526 Balance of 0.000000 fell below allowed amount of 1.000000! (Account 98)
782bbabe-fa1d-11e7-9318-47832fb85dfe 2018-01-15 18:56:53.560265 [INFO] mod_dialplan_xml.c:637 Processing +123456789 ->hangup in context test
According to the source code, the call is transferred to default "nobal_amt" which is "hangup". So the call is supposed to be stopped once this log is printed. Isn't it?
*De :*igor.potjevlesch@gmail.com [mailto:igor.potjevlesch@gmail.com] *Envoyé :* lundi 15 janvier 2018 18:51 *À :* 'FreeSWITCH Users Help' <freeswitch-users@lists.freeswitch.org> *Objet :* RE: [Freeswitch-users] Use Nibblebill with PostgreSQL
Ah ok, I didn't know nibble_current_balance. So with something like that should work, but unfortunately not:
<action application="set" data="nibble_account=98"/>
<action application="set" data="nibble_rate=0.0115"/>
<action application="set" data="nibble_minimum=1"/>
<action application="set" data="nibble_rounding=2"/>
<action application="set" data="heartbeat 1"/>
<action application="set" data="nibble_current_balance" inline="true"/>
<condition break="on-true" field="${cond(${nibble_current_balance} <= 0 ? YES : NO)}" expression="^YES$">
<action application="hangup" data="hangup_cause"/>
</condition>
The call is processed whereas balance in DB is equal to 0.
*De :*FreeSWITCH-users [mailto:freeswitch-users-bounces@lists.freeswitch.org] *De la part de* Madovsky *Envoyé :* lundi 15 janvier 2018 17:59 *À :* 'FreeSWITCH Users Help' <freeswitch-users@lists.freeswitch.org <mailto:freeswitch-users@lists.freeswitch.org>> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
I don't understand what is supposed to do the SQL request? I think that, indeed, nibble_balance is not set at the moment of the condition.
when you set the nibble account so nibblebill makes the SQL request you set in its config
to populate nibble_current_balance, so if you make a condition with nibble_current_balance just after set nibble_account
so you should set it inline to make the condition available
On 1/15/2018 5:29 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
Hello,
I'm still stuck with Nibblebill config. Even if the current balance is 0 or negative, the dialplan start the call.
Someone would have some examples of config where this behaviour is avoided? Thank you!
Regards,
Igor.
*De :*igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> [mailto:igor.potjevlesch@gmail.com] *Envoyé :* mercredi 10 janvier 2018 15:49 *À :* 'Madovsky' <infos@madovsky.org> <mailto:infos@madovsky.org> *Objet :* RE: [Freeswitch-users] Use Nibblebill with PostgreSQL
This is the log: Action log(INFO ${nibble_balance} is equal or lower than 0)
With or without "set nibble_balance". So I guess that this variable is undefined.
*De :*igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> [mailto:igor.potjevlesch@gmail.com] *Envoyé :* mercredi 10 janvier 2018 15:39 *À :* 'Madovsky' <infos@madovsky.org <mailto:infos@madovsky.org>> *Objet :* RE: [Freeswitch-users] Use Nibblebill with PostgreSQL
I don't understand what is supposed to do the SQL request? I think that, indeed, nibble_balance is not set at the moment of the condition.
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* mardi 9 janvier 2018 21:24 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
you should remove
<action application="set" data="nibble_balance" inline="true"/>
since when you populate nibble_account it makes automatically the SQL request and populate nibble_balance. then don't forget to put all nibble variables on the bridge like {nibble_account=${nibble_account},etc.}sofia/xxx
On 1/9/2018 8:14 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
I didn't. What does it mean "inline" in that case?
I tried like this and add "inline" on all settings. So, now the dialplan looks like this:
<action application="set" data="nibble_account=1" inline="true"/>
<action application="set" data="nibble_rate=1" inline="true"/>
<action application="set" data="nibble_minimum=1" inline="true"/>
<action application="set" data="nibble_rounding=2" inline="true"/>
<action application="set" data="nibble_balance" inline="true"/>
<action application="nibblebill" data="heartbeat 1"/>
<condition break="on-true" field="${cond(${nibble_balance} <= 0 ? YES : NO)}" expression="^YES$">
<action application="log" data="INFO ${nibble_balance} is equal or lower than 0"/>
</condition>
<action application="bridge" data="{nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/outbound/0$1"/>
The logs are showing the following outputs and the call start:
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_account=1) INLINE
8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_account=1)
8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_account]=[1]
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_rate=1) INLINE
8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_rate=1)
8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_rate]=[1]
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_minimum=1) INLINE
8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_minimum=1)
8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_minimum]=[1]
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_rounding=2) INLINE
8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_rounding=2)
8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_rounding]=[2]
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_balance) INLINE
8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_balance)
8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_balance]=[UNDEF]
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action nibblebill(heartbeat 1)
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action bridge({nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=}sofia/gateway/out/0123456789)
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action hangup(hangup_cause)
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* lundi 8 janvier 2018 19:52 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
did you set nibble balance inline="true" before the condition?
also check with log just after you set the var to be sure the SQL return a value
On 1/8/2018 10:24 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
I basically tried this:
<condition break="on-true" field="${cond(${nibble_balance} <= 0 ? YES : NO)}" expression="^YES$">
<action application="log" data="INFO ${nibble_balance} is equal or lower than 0"/>
</condition>
But I didn't see anything in the logs, the call begin to start.
Regards,
Igor
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* vendredi 5 janvier 2018 14:44 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
Yes in a nested condition for ex.
this method is more robust that trust nibblebill to do all the job
On 1/5/2018 5:33 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
It means that I can test ${nibble_balance} before right?
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* jeudi 4 janvier 2018 20:31 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
you should make a nested condition before the bridge
and if the balance not good transfer the call to hangup or something else
On 1/4/2018 8:03 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
I uncommented this in the config file of nibblebill:
<param name="custom_sql_lookup" value="SELECT euros AS nibble_balance FROM solde WHERE customer_id='${nibble_account}'"/>
The request is working fine according to the logs, but the call is still placed with the logs:
2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:422 Doing lookup query
[SELECT euros AS nibble_balance FROM solde WHERE customer_id='1']
2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:430 Retrieved current balance for account 1 (balance = -0.040000)
31fe25c6-f168-11e7-a065-b10720ff818b 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:523 Comparing -0.040000 to hangup balance of 1.000000, taking into account minimum charge of 1.000000
31fe25c6-f168-11e7-a065-b10720ff818b 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:526 Balance of -0.040000 fell below allowed amount of 1.000000! (Account 1)
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* jeudi 4 janvier 2018 16:37 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
add an sql request into nibblebill and link it to nibble_balance variables inline in diaplan
On 1/4/2018 7:35 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
Yes, why not, but I don't find how to check the balance before a bridge.
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* jeudi 4 janvier 2018 16:29 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
it starts because you don't have any user linked to your nibble_account
so the only way to not start the call is to create a condition with the nibble balance before
the bridge
On 1/4/2018 7:22 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
I did this:
dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_account=1)
dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1 /+4425482090@A.B.C.D <mailto:/+4425482090@A.B.C.D> Action set(nibble_rate=1)
dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_minimum=1)
dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_rounding=2)
dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action nibblebill(heartbeat 1)
dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action bridge({nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=}sofia/gateway/out_1/0123456789)
[…]
2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:430 Retrieved current balance for account 1 (balance = 0.000000)
dca7b05c-f161-11e7-9f9a-b10720ff818b 2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:523 Comparing 0.000000 to hangup balance of 1.000000, taking into account minimum charge of 1.000000
dca7b05c-f161-11e7-9f9a-b10720ff818b 2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:526 Balance of 0.000000 fell below allowed amount of 1.000000! (Account 1)
But the call still starts.
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* jeudi 4 janvier 2018 16:09 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
the nibblebill variables must be on the bridge like
<action application="bridge" data="{nibble_account=1,nibble_rate=1,etc....absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/out_01/0$1"/>
do not use "export" since I noticed some strange behavior with it. I don't know how nibblebill behaves without a nibble_account linked to a user account, so I cannot help for this case
On 1/4/2018 7:06 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
I don't have a registered user. It's a peer trusted by his IP address.
During the call the credit is updated every seconds but even without credit, the call start and stop immediately.
Yes I know. I will switch to more reasonable value after my tests.
What do you mean by "export all nibblebill variables to the bridge"?
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* jeudi 4 janvier 2018 15:52 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
> <action application="set" data="nibble_account=1"/>
is 1 a valid nibble_account of a registered user?
> <action application="nibblebill" data="check"/>
you dont' need to check, as nibblebill automatically check the balance
if the nibble_account is linked to a registered user
> <action application="nibblebill" data="heartbeat 1"/>
be aware that heartbeat to 1 means a request to your DB every second
about your issue you should export all nibblebill variables to the bridge too
On 1/4/2018 6:46 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
That's the case:
<condition break="on-true" expression="^\+44([1-9][0-9]{8})$" field="destination_number">
<action application="set" data="nibble_account=1"/>
<action application="nibblebill" data="check"/>
<action application="set" data="nibble_rate=1"/>
<action application="set" data="nibble_minimum=1"/>
<action application="set" data="nibble_rounding=2"/>
<action application="nibblebill" data="heartbeat 1"/>
<action application="bridge" data="{absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/out_01/0$1"/>
<action application="hangup" data="hangup_cause"/>
</condition>
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* jeudi 4 janvier 2018 12:41 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
you must check or set nibble_account before the call
On 1/4/2018 3:35 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
Hello,
Finally the billing works good. Would it be possible to setup the rates in db? I don't find example or documentation related to this.
Also, I don't understand why the call is allowed for bridging whereas the balance is 0 or negative?
Regards,
Igor.
*De :*igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> [mailto:igor.potjevlesch@gmail.com]
*Envoyé :* jeudi 4 janvier 2018 10:19 *À :* 'FreeSWITCH Users Help' <freeswitch-users@lists.freeswitch.org> <mailto:freeswitch-users@lists.freeswitch.org> *Objet :* RE: [Freeswitch-users] Use Nibblebill with PostgreSQL
Hello,
Thank you!
Both db_dsn and odbc-dsn work. db-dsn fails.
I keep the version with odbc-dsn because in that case I don't have the warning about deprecated function for versions earlier than 1.4.2 even if I run 1.6.
What is the best according to you? db_dsn or odbc-dsn?
I have additional questions related to nibble:
1. After hanging up the call, I see in the logs the good value: "mod_nibblebill.c:590 Billing $0.000234" but some line after there is another update: "mod_nibblebill.c:622 Rounding to precision 1.000000, total 1.000000 (0.999793 excess)". So the call is billed 1 instead of 0.000234. 2. Is it possible to setup in the db scheme different prefixes and their rate? Instead of putting them raw in the dialplan or any other config file?
Thank you in advance for your clarification.
Regards,
Igor.
*De :*FreeSWITCH-users [mailto:freeswitch-users-bounces@lists.freeswitch.org] *De la part de* Madovsky *Envoyé :* mercredi 3 janvier 2018 22:18 *À :* freeswitch-users@lists.freeswitch.org <mailto:freeswitch-users@lists.freeswitch.org> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
If you compiled FS with --enable-core-odbc-support so you can use
<param name="odbc-dsn" value="pgsql://hostaddr=xx.xx.xx.xx port=xxxx dbname=xxx user=xxx password='xxxx' options='-c client_min_messages=NOTICE' application_name='freeswitch'" />
you must set odbc.ini
On 1/3/2018 1:02 PM, Geoff Mina wrote:
I think the param is db-dsn. Not the underscore version.
On Jan 3, 2018, at 12:59 PM, Sergey Safarov <s.safarov@gmail.com <mailto:s.safarov@gmail.com>> wrote:
I used connection string
<param name="db_dsn" value="pgsql://hostaddr=127.0.0.1 dbname=******* user=******* password=*******"/>
Sergey
ср, 3 янв. 2018 г. в 22:06, <igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com>>:
Hello !
I try to connect Nibblebill directly to PostgreSQL but it still fails.
I follow the documentation and setup the param like this: <param name="odbc_dsn" value="pgsql://A.B.C.D dbname=prepaid user=prepaid password=<hidden>"/>
When I hangup a call, the logs report the following: 52c8b77c-f0b8-11e7-8d19-5566a3fb77f6 2018-01-03 20:00:19.037333 [CRIT] mod_nibblebill.c:604 Failed to log to database!
Any idea on how to proceed with FS 1.6? Thank you!
Regards,
Igor.
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com
Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com
Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
consulting@freeswitch.org <mailto:consulting@freeswitch.org>
http://www.freeswitchsolutions.com
Official FreeSWITCH Sites
http://confluence.freeswitch.org
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org>
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
consulting@freeswitch.org <mailto:consulting@freeswitch.org>
http://www.freeswitchsolutions.com
Official FreeSWITCH Sites
http://confluence.freeswitch.org
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org>
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Sorry I mixed the official var name with mine I use for other purpose. it's nibble_balance, not nibble_current_balance On 1/15/2018 9:50 AM, igor.potjevlesch@gmail.com wrote:
Ah ok, I didn't know nibble_current_balance. So with something like that should work, but unfortunately not:
<action application="set" data="nibble_account=98"/>
<action application="set" data="nibble_rate=0.0115"/>
<action application="set" data="nibble_minimum=1"/>
<action application="set" data="nibble_rounding=2"/>
<action application="set" data="heartbeat 1"/>
<action application="set" data="nibble_current_balance" inline="true"/>
<condition break="on-true" field="${cond(${nibble_current_balance} <= 0 ? YES : NO)}" expression="^YES$">
<action application="hangup" data="hangup_cause"/>
</condition>
The call is processed whereas balance in DB is equal to 0.
*De :*FreeSWITCH-users [mailto:freeswitch-users-bounces@lists.freeswitch.org] *De la part de* Madovsky *Envoyé :* lundi 15 janvier 2018 17:59 *À :* 'FreeSWITCH Users Help' <freeswitch-users@lists.freeswitch.org> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
I don't understand what is supposed to do the SQL request? I think that, indeed, nibble_balance is not set at the moment of the condition.
when you set the nibble account so nibblebill makes the SQL request you set in its config
to populate nibble_current_balance, so if you make a condition with nibble_current_balance just after set nibble_account
so you should set it inline to make the condition available
On 1/15/2018 5:29 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
Hello,
I'm still stuck with Nibblebill config. Even if the current balance is 0 or negative, the dialplan start the call.
Someone would have some examples of config where this behaviour is avoided? Thank you!
Regards,
Igor.
*De :*igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> [mailto:igor.potjevlesch@gmail.com] *Envoyé :* mercredi 10 janvier 2018 15:49 *À :* 'Madovsky' <infos@madovsky.org> <mailto:infos@madovsky.org> *Objet :* RE: [Freeswitch-users] Use Nibblebill with PostgreSQL
This is the log: Action log(INFO ${nibble_balance} is equal or lower than 0)
With or without "set nibble_balance". So I guess that this variable is undefined.
*De :*igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> [mailto:igor.potjevlesch@gmail.com] *Envoyé :* mercredi 10 janvier 2018 15:39 *À :* 'Madovsky' <infos@madovsky.org <mailto:infos@madovsky.org>> *Objet :* RE: [Freeswitch-users] Use Nibblebill with PostgreSQL
I don't understand what is supposed to do the SQL request? I think that, indeed, nibble_balance is not set at the moment of the condition.
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* mardi 9 janvier 2018 21:24 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
you should remove
<action application="set" data="nibble_balance" inline="true"/>
since when you populate nibble_account it makes automatically the SQL request and populate nibble_balance. then don't forget to put all nibble variables on the bridge like {nibble_account=${nibble_account},etc.}sofia/xxx
On 1/9/2018 8:14 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
I didn't. What does it mean "inline" in that case?
I tried like this and add "inline" on all settings. So, now the dialplan looks like this:
<action application="set" data="nibble_account=1" inline="true"/>
<action application="set" data="nibble_rate=1" inline="true"/>
<action application="set" data="nibble_minimum=1" inline="true"/>
<action application="set" data="nibble_rounding=2" inline="true"/>
<action application="set" data="nibble_balance" inline="true"/>
<action application="nibblebill" data="heartbeat 1"/>
<condition break="on-true" field="${cond(${nibble_balance} <= 0 ? YES : NO)}" expression="^YES$">
<action application="log" data="INFO ${nibble_balance} is equal or lower than 0"/>
</condition>
<action application="bridge" data="{nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/outbound/0$1"/>
The logs are showing the following outputs and the call start:
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_account=1) INLINE
8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_account=1)
8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_account]=[1]
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_rate=1) INLINE
8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_rate=1)
8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_rate]=[1]
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_minimum=1) INLINE
8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_minimum=1)
8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_minimum]=[1]
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_rounding=2) INLINE
8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_rounding=2)
8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_rounding]=[2]
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_balance) INLINE
8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_balance)
8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_balance]=[UNDEF]
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action nibblebill(heartbeat 1)
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action bridge({nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=}sofia/gateway/out/0123456789)
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action hangup(hangup_cause)
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* lundi 8 janvier 2018 19:52 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
did you set nibble balance inline="true" before the condition?
also check with log just after you set the var to be sure the SQL return a value
On 1/8/2018 10:24 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
I basically tried this:
<condition break="on-true" field="${cond(${nibble_balance} <= 0 ? YES : NO)}" expression="^YES$">
<action application="log" data="INFO ${nibble_balance} is equal or lower than 0"/>
</condition>
But I didn't see anything in the logs, the call begin to start.
Regards,
Igor
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* vendredi 5 janvier 2018 14:44 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
Yes in a nested condition for ex.
this method is more robust that trust nibblebill to do all the job
On 1/5/2018 5:33 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
It means that I can test ${nibble_balance} before right?
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* jeudi 4 janvier 2018 20:31 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
you should make a nested condition before the bridge
and if the balance not good transfer the call to hangup or something else
On 1/4/2018 8:03 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
I uncommented this in the config file of nibblebill:
<param name="custom_sql_lookup" value="SELECT euros AS nibble_balance FROM solde WHERE customer_id='${nibble_account}'"/>
The request is working fine according to the logs, but the call is still placed with the logs:
2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:422 Doing lookup query
[SELECT euros AS nibble_balance FROM solde WHERE customer_id='1']
2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:430 Retrieved current balance for account 1 (balance = -0.040000)
31fe25c6-f168-11e7-a065-b10720ff818b 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:523 Comparing -0.040000 to hangup balance of 1.000000, taking into account minimum charge of 1.000000
31fe25c6-f168-11e7-a065-b10720ff818b 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:526 Balance of -0.040000 fell below allowed amount of 1.000000! (Account 1)
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* jeudi 4 janvier 2018 16:37 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
add an sql request into nibblebill and link it to nibble_balance variables inline in diaplan
On 1/4/2018 7:35 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
Yes, why not, but I don't find how to check the balance before a bridge.
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* jeudi 4 janvier 2018 16:29 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
it starts because you don't have any user linked to your nibble_account
so the only way to not start the call is to create a condition with the nibble balance before
the bridge
On 1/4/2018 7:22 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
I did this:
dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_account=1)
dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1 /+4425482090@A.B.C.D <mailto:/+4425482090@A.B.C.D> Action set(nibble_rate=1)
dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_minimum=1)
dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_rounding=2)
dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action nibblebill(heartbeat 1)
dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action bridge({nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=}sofia/gateway/out_1/0123456789)
[…]
2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:430 Retrieved current balance for account 1 (balance = 0.000000)
dca7b05c-f161-11e7-9f9a-b10720ff818b 2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:523 Comparing 0.000000 to hangup balance of 1.000000, taking into account minimum charge of 1.000000
dca7b05c-f161-11e7-9f9a-b10720ff818b 2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:526 Balance of 0.000000 fell below allowed amount of 1.000000! (Account 1)
But the call still starts.
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* jeudi 4 janvier 2018 16:09 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
the nibblebill variables must be on the bridge like
<action application="bridge" data="{nibble_account=1,nibble_rate=1,etc....absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/out_01/0$1"/>
do not use "export" since I noticed some strange behavior with it. I don't know how nibblebill behaves without a nibble_account linked to a user account, so I cannot help for this case
On 1/4/2018 7:06 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
I don't have a registered user. It's a peer trusted by his IP address.
During the call the credit is updated every seconds but even without credit, the call start and stop immediately.
Yes I know. I will switch to more reasonable value after my tests.
What do you mean by "export all nibblebill variables to the bridge"?
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* jeudi 4 janvier 2018 15:52 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
> <action application="set" data="nibble_account=1"/>
is 1 a valid nibble_account of a registered user?
> <action application="nibblebill" data="check"/>
you dont' need to check, as nibblebill automatically check the balance
if the nibble_account is linked to a registered user
> <action application="nibblebill" data="heartbeat 1"/>
be aware that heartbeat to 1 means a request to your DB every second
about your issue you should export all nibblebill variables to the bridge too
On 1/4/2018 6:46 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
That's the case:
<condition break="on-true" expression="^\+44([1-9][0-9]{8})$" field="destination_number">
<action application="set" data="nibble_account=1"/>
<action application="nibblebill" data="check"/>
<action application="set" data="nibble_rate=1"/>
<action application="set" data="nibble_minimum=1"/>
<action application="set" data="nibble_rounding=2"/>
<action application="nibblebill" data="heartbeat 1"/>
<action application="bridge" data="{absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/out_01/0$1"/>
<action application="hangup" data="hangup_cause"/>
</condition>
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* jeudi 4 janvier 2018 12:41 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
you must check or set nibble_account before the call
On 1/4/2018 3:35 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
Hello,
Finally the billing works good. Would it be possible to setup the rates in db? I don't find example or documentation related to this.
Also, I don't understand why the call is allowed for bridging whereas the balance is 0 or negative?
Regards,
Igor.
*De :*igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> [mailto:igor.potjevlesch@gmail.com]
*Envoyé :* jeudi 4 janvier 2018 10:19 *À :* 'FreeSWITCH Users Help' <freeswitch-users@lists.freeswitch.org> <mailto:freeswitch-users@lists.freeswitch.org> *Objet :* RE: [Freeswitch-users] Use Nibblebill with PostgreSQL
Hello,
Thank you!
Both db_dsn and odbc-dsn work. db-dsn fails.
I keep the version with odbc-dsn because in that case I don't have the warning about deprecated function for versions earlier than 1.4.2 even if I run 1.6.
What is the best according to you? db_dsn or odbc-dsn?
I have additional questions related to nibble:
1. After hanging up the call, I see in the logs the good value: "mod_nibblebill.c:590 Billing $0.000234" but some line after there is another update: "mod_nibblebill.c:622 Rounding to precision 1.000000, total 1.000000 (0.999793 excess)". So the call is billed 1 instead of 0.000234. 2. Is it possible to setup in the db scheme different prefixes and their rate? Instead of putting them raw in the dialplan or any other config file?
Thank you in advance for your clarification.
Regards,
Igor.
*De :*FreeSWITCH-users [mailto:freeswitch-users-bounces@lists.freeswitch.org] *De la part de* Madovsky *Envoyé :* mercredi 3 janvier 2018 22:18 *À :* freeswitch-users@lists.freeswitch.org <mailto:freeswitch-users@lists.freeswitch.org> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
If you compiled FS with --enable-core-odbc-support so you can use
<param name="odbc-dsn" value="pgsql://hostaddr=xx.xx.xx.xx port=xxxx dbname=xxx user=xxx password='xxxx' options='-c client_min_messages=NOTICE' application_name='freeswitch'" />
you must set odbc.ini
On 1/3/2018 1:02 PM, Geoff Mina wrote:
I think the param is db-dsn. Not the underscore version.
On Jan 3, 2018, at 12:59 PM, Sergey Safarov <s.safarov@gmail.com <mailto:s.safarov@gmail.com>> wrote:
I used connection string
<param name="db_dsn" value="pgsql://hostaddr=127.0.0.1 dbname=******* user=******* password=*******"/>
Sergey
ср, 3 янв. 2018 г. в 22:06, <igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com>>:
Hello !
I try to connect Nibblebill directly to PostgreSQL but it still fails.
I follow the documentation and setup the param like this: <param name="odbc_dsn" value="pgsql://A.B.C.D dbname=prepaid user=prepaid password=<hidden>"/>
When I hangup a call, the logs report the following: 52c8b77c-f0b8-11e7-8d19-5566a3fb77f6 2018-01-03 20:00:19.037333 [CRIT] mod_nibblebill.c:604 Failed to log to database!
Any idea on how to proceed with FS 1.6? Thank you!
Regards,
Igor.
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com
Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com
Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
consulting@freeswitch.org <mailto:consulting@freeswitch.org>
http://www.freeswitchsolutions.com
Official FreeSWITCH Sites
http://confluence.freeswitch.org
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org>
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
consulting@freeswitch.org <mailto:consulting@freeswitch.org>
http://www.freeswitchsolutions.com
Official FreeSWITCH Sites
http://confluence.freeswitch.org
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org>
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
but btw you can set any variable name with your custom sql in nibblebill conf like <param name="custom_sql_lookup" value="SELECT cash AS nibble_hello_balance FROM accounts WHERE account_code='${nibble_account}'"/> On 1/15/2018 10:47 AM, Madovsky wrote:
Sorry I mixed the official var name with mine I use for other purpose.
it's nibble_balance, not nibble_current_balance
On 1/15/2018 9:50 AM, igor.potjevlesch@gmail.com wrote:
Ah ok, I didn't know nibble_current_balance. So with something like that should work, but unfortunately not:
<action application="set" data="nibble_account=98"/>
<action application="set" data="nibble_rate=0.0115"/>
<action application="set" data="nibble_minimum=1"/>
<action application="set" data="nibble_rounding=2"/>
<action application="set" data="heartbeat 1"/>
<action application="set" data="nibble_current_balance" inline="true"/>
<condition break="on-true" field="${cond(${nibble_current_balance} <= 0 ? YES : NO)}" expression="^YES$">
<action application="hangup" data="hangup_cause"/>
</condition>
The call is processed whereas balance in DB is equal to 0.
*De :*FreeSWITCH-users [mailto:freeswitch-users-bounces@lists.freeswitch.org] *De la part de* Madovsky *Envoyé :* lundi 15 janvier 2018 17:59 *À :* 'FreeSWITCH Users Help' <freeswitch-users@lists.freeswitch.org> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
I don't understand what is supposed to do the SQL request? I think that, indeed, nibble_balance is not set at the moment of the condition.
when you set the nibble account so nibblebill makes the SQL request you set in its config
to populate nibble_current_balance, so if you make a condition with nibble_current_balance just after set nibble_account
so you should set it inline to make the condition available
On 1/15/2018 5:29 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
Hello,
I'm still stuck with Nibblebill config. Even if the current balance is 0 or negative, the dialplan start the call.
Someone would have some examples of config where this behaviour is avoided? Thank you!
Regards,
Igor.
*De :*igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> [mailto:igor.potjevlesch@gmail.com] *Envoyé :* mercredi 10 janvier 2018 15:49 *À :* 'Madovsky' <infos@madovsky.org> <mailto:infos@madovsky.org> *Objet :* RE: [Freeswitch-users] Use Nibblebill with PostgreSQL
This is the log: Action log(INFO ${nibble_balance} is equal or lower than 0)
With or without "set nibble_balance". So I guess that this variable is undefined.
*De :*igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> [mailto:igor.potjevlesch@gmail.com] *Envoyé :* mercredi 10 janvier 2018 15:39 *À :* 'Madovsky' <infos@madovsky.org <mailto:infos@madovsky.org>> *Objet :* RE: [Freeswitch-users] Use Nibblebill with PostgreSQL
I don't understand what is supposed to do the SQL request? I think that, indeed, nibble_balance is not set at the moment of the condition.
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* mardi 9 janvier 2018 21:24 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
you should remove
<action application="set" data="nibble_balance" inline="true"/>
since when you populate nibble_account it makes automatically the SQL request and populate nibble_balance. then don't forget to put all nibble variables on the bridge like {nibble_account=${nibble_account},etc.}sofia/xxx
On 1/9/2018 8:14 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
I didn't. What does it mean "inline" in that case?
I tried like this and add "inline" on all settings. So, now the dialplan looks like this:
<action application="set" data="nibble_account=1" inline="true"/>
<action application="set" data="nibble_rate=1" inline="true"/>
<action application="set" data="nibble_minimum=1" inline="true"/>
<action application="set" data="nibble_rounding=2" inline="true"/>
<action application="set" data="nibble_balance" inline="true"/>
<action application="nibblebill" data="heartbeat 1"/>
<condition break="on-true" field="${cond(${nibble_balance} <= 0 ? YES : NO)}" expression="^YES$">
<action application="log" data="INFO ${nibble_balance} is equal or lower than 0"/>
</condition>
<action application="bridge" data="{nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/outbound/0$1"/>
The logs are showing the following outputs and the call start:
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_account=1) INLINE
8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_account=1)
8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_account]=[1]
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_rate=1) INLINE
8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_rate=1)
8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_rate]=[1]
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_minimum=1) INLINE
8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_minimum=1)
8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_minimum]=[1]
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_rounding=2) INLINE
8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_rounding=2)
8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_rounding]=[2]
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_balance) INLINE
8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_balance)
8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_balance]=[UNDEF]
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action nibblebill(heartbeat 1)
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action bridge({nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=}sofia/gateway/out/0123456789)
8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action hangup(hangup_cause)
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* lundi 8 janvier 2018 19:52 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
did you set nibble balance inline="true" before the condition?
also check with log just after you set the var to be sure the SQL return a value
On 1/8/2018 10:24 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
I basically tried this:
<condition break="on-true" field="${cond(${nibble_balance} <= 0 ? YES : NO)}" expression="^YES$">
<action application="log" data="INFO ${nibble_balance} is equal or lower than 0"/>
</condition>
But I didn't see anything in the logs, the call begin to start.
Regards,
Igor
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* vendredi 5 janvier 2018 14:44 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
Yes in a nested condition for ex.
this method is more robust that trust nibblebill to do all the job
On 1/5/2018 5:33 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
It means that I can test ${nibble_balance} before right?
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* jeudi 4 janvier 2018 20:31 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
you should make a nested condition before the bridge
and if the balance not good transfer the call to hangup or something else
On 1/4/2018 8:03 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
I uncommented this in the config file of nibblebill:
<param name="custom_sql_lookup" value="SELECT euros AS nibble_balance FROM solde WHERE customer_id='${nibble_account}'"/>
The request is working fine according to the logs, but the call is still placed with the logs:
2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:422 Doing lookup query
[SELECT euros AS nibble_balance FROM solde WHERE customer_id='1']
2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:430 Retrieved current balance for account 1 (balance = -0.040000)
31fe25c6-f168-11e7-a065-b10720ff818b 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:523 Comparing -0.040000 to hangup balance of 1.000000, taking into account minimum charge of 1.000000
31fe25c6-f168-11e7-a065-b10720ff818b 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:526 Balance of -0.040000 fell below allowed amount of 1.000000! (Account 1)
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* jeudi 4 janvier 2018 16:37 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
add an sql request into nibblebill and link it to nibble_balance variables inline in diaplan
On 1/4/2018 7:35 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
Yes, why not, but I don't find how to check the balance before a bridge.
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* jeudi 4 janvier 2018 16:29 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
it starts because you don't have any user linked to your nibble_account
so the only way to not start the call is to create a condition with the nibble balance before
the bridge
On 1/4/2018 7:22 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
I did this:
dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_account=1)
dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1 /+4425482090@A.B.C.D <mailto:/+4425482090@A.B.C.D> Action set(nibble_rate=1)
dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_minimum=1)
dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_rounding=2)
dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action nibblebill(heartbeat 1)
dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action bridge({nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=}sofia/gateway/out_1/0123456789)
[…]
2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:430 Retrieved current balance for account 1 (balance = 0.000000)
dca7b05c-f161-11e7-9f9a-b10720ff818b 2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:523 Comparing 0.000000 to hangup balance of 1.000000, taking into account minimum charge of 1.000000
dca7b05c-f161-11e7-9f9a-b10720ff818b 2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:526 Balance of 0.000000 fell below allowed amount of 1.000000! (Account 1)
But the call still starts.
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* jeudi 4 janvier 2018 16:09 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
the nibblebill variables must be on the bridge like
<action application="bridge" data="{nibble_account=1,nibble_rate=1,etc....absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/out_01/0$1"/>
do not use "export" since I noticed some strange behavior with it. I don't know how nibblebill behaves without a nibble_account linked to a user account, so I cannot help for this case
On 1/4/2018 7:06 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
I don't have a registered user. It's a peer trusted by his IP address.
During the call the credit is updated every seconds but even without credit, the call start and stop immediately.
Yes I know. I will switch to more reasonable value after my tests.
What do you mean by "export all nibblebill variables to the bridge"?
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* jeudi 4 janvier 2018 15:52 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
> <action application="set" data="nibble_account=1"/>
is 1 a valid nibble_account of a registered user?
> <action application="nibblebill" data="check"/>
you dont' need to check, as nibblebill automatically check the balance
if the nibble_account is linked to a registered user
> <action application="nibblebill" data="heartbeat 1"/>
be aware that heartbeat to 1 means a request to your DB every second
about your issue you should export all nibblebill variables to the bridge too
On 1/4/2018 6:46 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
That's the case:
<condition break="on-true" expression="^\+44([1-9][0-9]{8})$" field="destination_number">
<action application="set" data="nibble_account=1"/>
<action application="nibblebill" data="check"/>
<action application="set" data="nibble_rate=1"/>
<action application="set" data="nibble_minimum=1"/>
<action application="set" data="nibble_rounding=2"/>
<action application="nibblebill" data="heartbeat 1"/>
<action application="bridge" data="{absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/out_01/0$1"/>
<action application="hangup" data="hangup_cause"/>
</condition>
*De :*Madovsky [mailto:infos@madovsky.org] *Envoyé :* jeudi 4 janvier 2018 12:41 *À :* igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
you must check or set nibble_account before the call
On 1/4/2018 3:35 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote:
Hello,
Finally the billing works good. Would it be possible to setup the rates in db? I don't find example or documentation related to this.
Also, I don't understand why the call is allowed for bridging whereas the balance is 0 or negative?
Regards,
Igor.
*De :*igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> [mailto:igor.potjevlesch@gmail.com]
*Envoyé :* jeudi 4 janvier 2018 10:19 *À :* 'FreeSWITCH Users Help' <freeswitch-users@lists.freeswitch.org> <mailto:freeswitch-users@lists.freeswitch.org> *Objet :* RE: [Freeswitch-users] Use Nibblebill with PostgreSQL
Hello,
Thank you!
Both db_dsn and odbc-dsn work. db-dsn fails.
I keep the version with odbc-dsn because in that case I don't have the warning about deprecated function for versions earlier than 1.4.2 even if I run 1.6.
What is the best according to you? db_dsn or odbc-dsn?
I have additional questions related to nibble:
1. After hanging up the call, I see in the logs the good value: "mod_nibblebill.c:590 Billing $0.000234" but some line after there is another update: "mod_nibblebill.c:622 Rounding to precision 1.000000, total 1.000000 (0.999793 excess)". So the call is billed 1 instead of 0.000234. 2. Is it possible to setup in the db scheme different prefixes and their rate? Instead of putting them raw in the dialplan or any other config file?
Thank you in advance for your clarification.
Regards,
Igor.
*De :*FreeSWITCH-users [mailto:freeswitch-users-bounces@lists.freeswitch.org] *De la part de* Madovsky *Envoyé :* mercredi 3 janvier 2018 22:18 *À :* freeswitch-users@lists.freeswitch.org <mailto:freeswitch-users@lists.freeswitch.org> *Objet :* Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
If you compiled FS with --enable-core-odbc-support so you can use
<param name="odbc-dsn" value="pgsql://hostaddr=xx.xx.xx.xx port=xxxx dbname=xxx user=xxx password='xxxx' options='-c client_min_messages=NOTICE' application_name='freeswitch'" />
you must set odbc.ini
On 1/3/2018 1:02 PM, Geoff Mina wrote:
I think the param is db-dsn. Not the underscore version.
On Jan 3, 2018, at 12:59 PM, Sergey Safarov <s.safarov@gmail.com <mailto:s.safarov@gmail.com>> wrote:
I used connection string
<param name="db_dsn" value="pgsql://hostaddr=127.0.0.1 dbname=******* user=******* password=*******"/>
Sergey
ср, 3 янв. 2018 г. в 22:06, <igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com>>:
Hello !
I try to connect Nibblebill directly to PostgreSQL but it still fails.
I follow the documentation and setup the param like this: <param name="odbc_dsn" value="pgsql://A.B.C.D dbname=prepaid user=prepaid password=<hidden>"/>
When I hangup a call, the logs report the following: 52c8b77c-f0b8-11e7-8d19-5566a3fb77f6 2018-01-03 20:00:19.037333 [CRIT] mod_nibblebill.c:604 Failed to log to database!
Any idea on how to proceed with FS 1.6? Thank you!
Regards,
Igor.
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com
Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com
Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
consulting@freeswitch.org <mailto:consulting@freeswitch.org>
http://www.freeswitchsolutions.com
Official FreeSWITCH Sites
http://confluence.freeswitch.org
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org>
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
consulting@freeswitch.org <mailto:consulting@freeswitch.org>
http://www.freeswitchsolutions.com
Official FreeSWITCH Sites
http://confluence.freeswitch.org
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org>
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
I understand. Thank you Madovsky for your help! De : FreeSWITCH-users [mailto:freeswitch-users-bounces@lists.freeswitch.org] De la part de Madovsky Envoyé : lundi 15 janvier 2018 19:57 À : freeswitch-users@lists.freeswitch.org Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL but btw you can set any variable name with your custom sql in nibblebill conf like <param name="custom_sql_lookup" value="SELECT cash AS nibble_hello_balance FROM accounts WHERE account_code='${nibble_account}'"/> On 1/15/2018 10:47 AM, Madovsky wrote: Sorry I mixed the official var name with mine I use for other purpose. it's nibble_balance, not nibble_current_balance On 1/15/2018 9:50 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: Ah ok, I didn't know nibble_current_balance. So with something like that should work, but unfortunately not: <action application="set" data="nibble_account=98"/> <action application="set" data="nibble_rate=0.0115"/> <action application="set" data="nibble_minimum=1"/> <action application="set" data="nibble_rounding=2"/> <action application="set" data="heartbeat 1"/> <action application="set" data="nibble_current_balance" inline="true"/> <condition break="on-true" field="${cond(${nibble_current_balance} <= 0 ? YES : NO)}" expression="^YES$"> <action application="hangup" data="hangup_cause"/> </condition> The call is processed whereas balance in DB is equal to 0. De : FreeSWITCH-users [mailto:freeswitch-users-bounces@lists.freeswitch.org] De la part de Madovsky Envoyé : lundi 15 janvier 2018 17:59 À : 'FreeSWITCH Users Help' <mailto:freeswitch-users@lists.freeswitch.org> <freeswitch-users@lists.freeswitch.org> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
I don't understand what is supposed to do the SQL request? I think that, indeed, nibble_balance is not set at the moment of the condition.
when you set the nibble account so nibblebill makes the SQL request you set in its config to populate nibble_current_balance, so if you make a condition with nibble_current_balance just after set nibble_account so you should set it inline to make the condition available On 1/15/2018 5:29 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: Hello, I'm still stuck with Nibblebill config. Even if the current balance is 0 or negative, the dialplan start the call. Someone would have some examples of config where this behaviour is avoided? Thank you! Regards, Igor. De : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> [mailto:igor.potjevlesch@gmail.com] Envoyé : mercredi 10 janvier 2018 15:49 À : 'Madovsky' <mailto:infos@madovsky.org> <infos@madovsky.org> Objet : RE: [Freeswitch-users] Use Nibblebill with PostgreSQL This is the log: Action log(INFO ${nibble_balance} is equal or lower than 0) With or without "set nibble_balance". So I guess that this variable is undefined. De : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> [mailto:igor.potjevlesch@gmail.com] Envoyé : mercredi 10 janvier 2018 15:39 À : 'Madovsky' <infos@madovsky.org <mailto:infos@madovsky.org> > Objet : RE: [Freeswitch-users] Use Nibblebill with PostgreSQL I don't understand what is supposed to do the SQL request? I think that, indeed, nibble_balance is not set at the moment of the condition. De : Madovsky [mailto:infos@madovsky.org] Envoyé : mardi 9 janvier 2018 21:24 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL you should remove <action application="set" data="nibble_balance" inline="true"/> since when you populate nibble_account it makes automatically the SQL request and populate nibble_balance. then don't forget to put all nibble variables on the bridge like {nibble_account=${nibble_account},etc.}sofia/xxx On 1/9/2018 8:14 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: I didn't. What does it mean "inline" in that case? I tried like this and add "inline" on all settings. So, now the dialplan looks like this: <action application="set" data="nibble_account=1" inline="true"/> <action application="set" data="nibble_rate=1" inline="true"/> <action application="set" data="nibble_minimum=1" inline="true"/> <action application="set" data="nibble_rounding=2" inline="true"/> <action application="set" data="nibble_balance" inline="true"/> <action application="nibblebill" data="heartbeat 1"/> <condition break="on-true" field="${cond(${nibble_balance} <= 0 ? YES : NO)}" expression="^YES$"> <action application="log" data="INFO ${nibble_balance} is equal or lower than 0"/> </condition> <action application="bridge" data="{nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/outbound/0$1"/> The logs are showing the following outputs and the call start: 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_account=1) INLINE 8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_account=1) 8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_account]=[1] 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_rate=1) INLINE 8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_rate=1) 8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_rate]=[1] 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_minimum=1) INLINE 8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_minimum=1) 8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_minimum]=[1] 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_rounding=2) INLINE 8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_rounding=2) 8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_rounding]=[2] 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action set(nibble_balance) INLINE 8d308628-f555-11e7-9064-df48dc662f2c EXECUTE sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> set(nibble_balance) 8d308628-f555-11e7-9064-df48dc662f2c 2018-01-09 16:55:44.782489 [DEBUG] mod_dptools.c:1548 SET sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> [nibble_balance]=[UNDEF] 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action nibblebill(heartbeat 1) 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action bridge({nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=}sofia/gateway/out/0123456789) 8d308628-f555-11e7-9064-df48dc662f2c |--- Dialplan: sofia/client_in/+123456789@A.B.C.D <mailto:sofia/client_in/+123456789@A.B.C.D> Action hangup(hangup_cause) De : Madovsky [mailto:infos@madovsky.org] Envoyé : lundi 8 janvier 2018 19:52 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL did you set nibble balance inline="true" before the condition? also check with log just after you set the var to be sure the SQL return a value On 1/8/2018 10:24 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: I basically tried this: <condition break="on-true" field="${cond(${nibble_balance} <= 0 ? YES : NO)}" expression="^YES$"> <action application="log" data="INFO ${nibble_balance} is equal or lower than 0"/> </condition> But I didn't see anything in the logs, the call begin to start. Regards, Igor De : Madovsky [mailto:infos@madovsky.org] Envoyé : vendredi 5 janvier 2018 14:44 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL Yes in a nested condition for ex. this method is more robust that trust nibblebill to do all the job On 1/5/2018 5:33 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: It means that I can test ${nibble_balance} before right? De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 20:31 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL you should make a nested condition before the bridge and if the balance not good transfer the call to hangup or something else On 1/4/2018 8:03 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: I uncommented this in the config file of nibblebill: <param name="custom_sql_lookup" value="SELECT euros AS nibble_balance FROM solde WHERE customer_id='${nibble_account}'"/> The request is working fine according to the logs, but the call is still placed with the logs: 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:422 Doing lookup query [SELECT euros AS nibble_balance FROM solde WHERE customer_id='1'] 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:430 Retrieved current balance for account 1 (balance = -0.040000) 31fe25c6-f168-11e7-a065-b10720ff818b 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:523 Comparing -0.040000 to hangup balance of 1.000000, taking into account minimum charge of 1.000000 31fe25c6-f168-11e7-a065-b10720ff818b 2018-01-04 16:59:07.571051 [DEBUG] mod_nibblebill.c:526 Balance of -0.040000 fell below allowed amount of 1.000000! (Account 1) De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 16:37 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL add an sql request into nibblebill and link it to nibble_balance variables inline in diaplan On 1/4/2018 7:35 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: Yes, why not, but I don't find how to check the balance before a bridge. De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 16:29 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL it starts because you don't have any user linked to your nibble_account so the only way to not start the call is to create a condition with the nibble balance before the bridge On 1/4/2018 7:22 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: I did this: dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_account=1) dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1 /+4425482090@A.B.C.D <mailto:/+4425482090@A.B.C.D> Action set(nibble_rate=1) dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_minimum=1) dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action set(nibble_rounding=2) dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action nibblebill(heartbeat 1) dca705f8-f161-11e7-9f81-b10720ff818b |--- Dialplan: sofia/trunk1/+4425482090@A.B.C.D <mailto:sofia/trunk1/+4425482090@A.B.C.D> Action bridge({nibble_account=1,nibble_rate=1,nibble_minimum=1,nibble_rounding=2,absolute_codec_string=PCMA,101,sip_invite_domain=}sofia/gateway/out_1/0123456789) […] 2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:430 Retrieved current balance for account 1 (balance = 0.000000) dca7b05c-f161-11e7-9f9a-b10720ff818b 2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:523 Comparing 0.000000 to hangup balance of 1.000000, taking into account minimum charge of 1.000000 dca7b05c-f161-11e7-9f9a-b10720ff818b 2018-01-04 16:13:47.410971 [DEBUG] mod_nibblebill.c:526 Balance of 0.000000 fell below allowed amount of 1.000000! (Account 1) But the call still starts. De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 16:09 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL the nibblebill variables must be on the bridge like <action application="bridge" data="{nibble_account=1,nibble_rate=1,etc....absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/out_01/0$1"/> do not use "export" since I noticed some strange behavior with it. I don't know how nibblebill behaves without a nibble_account linked to a user account, so I cannot help for this case On 1/4/2018 7:06 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: I don't have a registered user. It's a peer trusted by his IP address. During the call the credit is updated every seconds but even without credit, the call start and stop immediately. Yes I know. I will switch to more reasonable value after my tests. What do you mean by "export all nibblebill variables to the bridge"? De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 15:52 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL
<action application="set" data="nibble_account=1"/>
is 1 a valid nibble_account of a registered user?
<action application="nibblebill" data="check"/>
you dont' need to check, as nibblebill automatically check the balance if the nibble_account is linked to a registered user
<action application="nibblebill" data="heartbeat 1"/>
be aware that heartbeat to 1 means a request to your DB every second about your issue you should export all nibblebill variables to the bridge too On 1/4/2018 6:46 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: That's the case: <condition break="on-true" expression="^\+44([1-9][0-9]{8})$" field="destination_number"> <action application="set" data="nibble_account=1"/> <action application="nibblebill" data="check"/> <action application="set" data="nibble_rate=1"/> <action application="set" data="nibble_minimum=1"/> <action application="set" data="nibble_rounding=2"/> <action application="nibblebill" data="heartbeat 1"/> <action application="bridge" data="{absolute_codec_string=PCMA,101,sip_invite_domain=$${ext-sip-ip}}sofia/gateway/out_01/0$1"/> <action application="hangup" data="hangup_cause"/> </condition> De : Madovsky [mailto:infos@madovsky.org] Envoyé : jeudi 4 janvier 2018 12:41 À : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL you must check or set nibble_account before the call On 1/4/2018 3:35 AM, igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> wrote: Hello, Finally the billing works good. Would it be possible to setup the rates in db? I don't find example or documentation related to this. Also, I don't understand why the call is allowed for bridging whereas the balance is 0 or negative? Regards, Igor. De : igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> [mailto:igor.potjevlesch@gmail.com] Envoyé : jeudi 4 janvier 2018 10:19 À : 'FreeSWITCH Users Help' <mailto:freeswitch-users@lists.freeswitch.org> <freeswitch-users@lists.freeswitch.org> Objet : RE: [Freeswitch-users] Use Nibblebill with PostgreSQL Hello, Thank you! Both db_dsn and odbc-dsn work. db-dsn fails. I keep the version with odbc-dsn because in that case I don't have the warning about deprecated function for versions earlier than 1.4.2 even if I run 1.6. What is the best according to you? db_dsn or odbc-dsn? I have additional questions related to nibble: 1. After hanging up the call, I see in the logs the good value: "mod_nibblebill.c:590 Billing $0.000234" but some line after there is another update: "mod_nibblebill.c:622 Rounding to precision 1.000000, total 1.000000 (0.999793 excess)". So the call is billed 1 instead of 0.000234. 2. Is it possible to setup in the db scheme different prefixes and their rate? Instead of putting them raw in the dialplan or any other config file? Thank you in advance for your clarification. Regards, Igor. De : FreeSWITCH-users [mailto:freeswitch-users-bounces@lists.freeswitch.org] De la part de Madovsky Envoyé : mercredi 3 janvier 2018 22:18 À : freeswitch-users@lists.freeswitch.org <mailto:freeswitch-users@lists.freeswitch.org> Objet : Re: [Freeswitch-users] Use Nibblebill with PostgreSQL If you compiled FS with --enable-core-odbc-support so you can use <param name="odbc-dsn" value="pgsql://hostaddr=xx.xx.xx.xx port=xxxx dbname=xxx user=xxx password='xxxx' options='-c client_min_messages=NOTICE' application_name='freeswitch'" /> you must set odbc.ini On 1/3/2018 1:02 PM, Geoff Mina wrote: I think the param is db-dsn. Not the underscore version. On Jan 3, 2018, at 12:59 PM, Sergey Safarov <s.safarov@gmail.com <mailto:s.safarov@gmail.com> > wrote: I used connection string <param name="db_dsn" value="pgsql://hostaddr=127.0.0.1 dbname=******* user=******* password=*******"/> Sergey ср, 3 янв. 2018 г. в 22:06, <igor.potjevlesch@gmail.com <mailto:igor.potjevlesch@gmail.com> >: Hello ! I try to connect Nibblebill directly to PostgreSQL but it still fails. I follow the documentation and setup the param like this: <param name="odbc_dsn" value="pgsql://A.B.C.D dbname=prepaid user=prepaid password=<hidden>"/> When I hangup a call, the logs report the following: 52c8b77c-f0b8-11e7-8d19-5566a3fb77f6 2018-01-03 20:00:19.037333 [CRIT] mod_nibblebill.c:604 Failed to log to database! Any idea on how to proceed with FS 1.6? Thank you! Regards, Igor. _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
participants (3)
-
igor.potjevlesch@gmail.com
-
Madovsky
-
Michael Jerris