1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Check out the 6 new Certified Incredible PBX Builds for Asterisk 11 and 13 featuring CentOS 6, Ubuntu 14, Raspberry Pi 2, and Asterisk-NOW.
    Dismiss Notice

A2Billing - An Adventure in PBX Billing - Part 1

Discussion in 'Add-On Install Instructions' started by tshif, Dec 18, 2008.

  1. jbh

    jbh Guru

    Many thanks Joe. The solution to a problem I had not yet realised I had !
  2. sri2talk

    sri2talk New Member

    Only Certain extensions are sent through a2b

    I think you can set up 2 trunks. 1 set of trunks require 9 as a prefix. These are sent to a2b. The extension ATAs that need to be billed will have a dialing prefix of 9 set in their config so that any number they dial will be prefixed with 9.
  3. jroper

    jroper Guru


    The solution offered above is one way, the other is to use the system blogged on by Jeff Howe, one of our forum members, and described here:-


    Chose the A2Billing trunk, or send the call straight out.

    Alternatively, send all calls out via A2Billing, and create a callplan that does not charge certain callers for calls.

  4. sri2talk

    sri2talk New Member

    Thanks for the above suggestion for using the Jeff Howe method. In fact it is much better and cleaner than using the ATAs to prepend 9. The issue with ATAs prepending 9 was that a *97 would come in as 9*97 - unacceptable.
  5. sri2talk

    sri2talk New Member

    I am not getting the user prompts for prepaid-welcome etc. Are they synthesized on the fly? i.e. Do I need to have festival/cepstral on the same machine as asterisk/a2billing?
  6. Bart

    Bart Member

    Call Report - CDR Report show wrong time

    The server reports correct time and timezone in php.ini is correct so I've ran out of places to check - I appears +7 ahead.

    What am I missing?

  7. dbenwit

    dbenwit New Member

    Handling Multiple Incoming DIDs + Company Directory Issue

    I have used this article to set up serveral installations of A2Billing to bill for incoming and outgoing calls on asterisk-based PBXs and it has been invaluable. Thus, I would like to relate my experiences in dealing with the setup of multiple incoming DIDs which require different rating. (ie. local DID + several Toll Free DIDs) What I will describe may be obvious to many, but was certainly not to me. I would also like to warn of a problem which I have encountered with the Company Directory using this approach.

    I set up an incoming route for each of the DIDs and send it to the A2B-DID custom destination. As I want each of these incoming DID calls to hit the auto-attendant, I have set up a custom feature code using Misc. Applications with its destination being the IVR for the auto-attendant, just as outlined in this article, for each of the DIDs (ie. 900, 901, 902). I then create an entry under Incoming DID - Destination in A2Billing for each of the DIDs, using a different custom feature code as the destination for each of the DIDs. This then allows me to set up separate rate for each of the DIDs and A2Billing will rate incoming calls on each DID accordingly.

    The configuration has worked well, except for one issue which has been both annoying and dangerous. It has to do with an incoming call in which the caller selects to use the Company Directory option (pressing the # key) and then hangs up before connecting through to an extension. The result of this is a looping created in the Asterisk CLI and ultimately an uncontrollable growth in the asterisk log file leading to the crashing of asterisk or a full disk drive after several days, if the problem is not detected. The only way to stop this, as far as I have been able to determine, is to reboot the server.
    The loop in the /var/log/asterisk/full log is as follows:

    From Asterisk CLI [2009-06-23 23:20:38] WARNING[3517] file.c: Failed to write frame
    [2009-06-23 23:20:38] VERBOSE[3517] logger.c: -- <Local/900@from-internal-e886,2> Playing 'dir-intro-fnln-oper' (language 'en')
    [2009-06-23 23:20:38] VERBOSE[3517] logger.c: -- Playing 'dir-nomatch' (escape_digits=) (sample_offset 0)
    [2009-06-23 23:20:38] WARNING[3517] file.c: Failed to write frame
    [2009-06-23 23:20:38] WARNING[3517] file.c: Failed to write frame
    [2009-06-23 23:20:38] VERBOSE[3517] logger.c: -- <Local/900@from-internal-e886,2> Playing 'dir-intro-fnln-oper' (language 'en')
    [2009-06-23 23:20:38] VERBOSE[3517] logger.c: -- Playing 'dir-nomatch' (escape_digits=) (sample_offset 0)
    [2009-06-23 23:20:38] WARNING[3517] file.c: Failed to write frame
    [2009-06-23 23:20:38] WARNING[3517] file.c: Failed to write frame
    [2009-06-23 23:20:38] VERBOSE[3517] logger.c: -- <Local/900@from-internal-e886,2> Playing 'dir-intro-fnln-oper' (language 'en')

    If you open the Asterisk CLI, you will observe the following lines scrolling by continuously:

    From Asterisk CLI -- Playing 'dir-nomatch' (escape_digits=) (sample_offset 0)
    -- <Local/900@from-internal-e886,2> Playing 'dir-intro-fnln-oper' (language 'en')
    -- Playing 'dir-nomatch' (escape_digits=) (sample_offset 0)
    -- <Local/900@from-internal-e886,2> Playing 'dir-intro-fnln-oper' (language 'en')
    -- Playing 'dir-nomatch' (escape_digits=) (sample_offset 0)
    …<Local/900@from-internal-e886,2> Playing 'dir-intro-fnln-oper' (language 'en')

    This is the tell tale sign of the problem beyond the large log files.

    I have been able to isolate this problem to the routing of the incoming call through A2Billing as I cannot reproduce it if I bypass A2Billing in the incoming route (ie. do not use A2B-DID as the destination, but rather the IVR). I have read that this problem is related to the use of the custom feature code for setting a destination for incoming DID calls, but there was no solution offered.

    Has anyone else experienced this problem, and, if so, have any solution?

  8. jroper

    jroper Guru


    If you have a number of customers where you wish to rate the incoming DID, and for that matter outbound calls, then it may be an idea to bring the DID to your own central A2Billing server, and do the rating there.

    Other than that, I do not see any immediate way around the problem. The rating of the DID is a convoluted solution, and would be better served by doing it code.

    We are looking at a solution for 1.4 where the A leg is rated, and added to the B leg, however there is other stuff further up the priority list at the moment.

    In as much as rebooting is concerned, issuing the command amportal kill, followed by amportal start should avoid the need to reboot.

  9. wardmundy

    wardmundy Nerd Uno

    That's a a pretty dangerous bug if anyone on your server can dial in, press #, hang up, and know that the server is destined to crash. What could be more important than fixing that? :confused5:
  10. jroper

    jroper Guru


    The methodology used to rate an inbound call is somewhat convoluted.

    As you know, the call comes into FreePBX as an inbound route, and we send it off to A2Billing tagged as a DID.

    When it arrives at A2Billing, the destination has to go through a trunk in order to be rated.

    So a trunk of technology "Local" is created to the appropriate context - usually the "from-internal" context.

    Now this is a bodge to achieve this particular functionality, of rating DID by the minute. Normally DID are delivered for a fixed monthly cost, and no per minute charges, and so there is usually no need to follow this methodology.

    However, more and more DID providers are charging by the minute, and as such we are doing development work to be able to charge the A Leg, or indeed credit the A Leg for Revenue share numbers, and add (or subtract) the cost to the B Leg.

    However, A2Billing has never been designed to add the A Leg to the BLeg, so some major re-writes are required.

    If you use any product in the way that it was not designed to work, then problems can be expected.

    Such is the beauty of open source, we can all, if we wish, apply some ingenuity, thought and consideration to the problem.
  11. wardmundy

    wardmundy Nerd Uno

    That makes perfect sense if we were talking about providers using a product in an unanticipated way. But this involves end users being able to destroy an Asterisk server by pressing # and then hanging up.

    It's really <strike>disingenuous</strike> inappropriate to attribute the bug to "the beauty of open source" or leave it for others to fix. :crazy:
  12. jroper

    jroper Guru

    Sending the call into FreePBX, sending it into A2Billing, looping it back into the company directory, rather than an extension or ring group was not something that was tested, and we did not anticipate this particular scenario, when writing the instructions. I would re-iterate that it may be best to avoid using this methodology for this particular scenario, until the time is found to look at this issue in more detail, to work out whether the issue lies in FreePBX dial plan or the asterisk dial command.

    The last act that A2Billing does, is send a dial command back to asterisk, so this may be the area to concentrate on.

    In respect of your comment, disingenuous defined as not candid or sincere, especially in feigning ignorance

    (source - http://www.askoxford.com/concise_oed/disingenuous?view=uk)

    I'm not sure whether that is a fair comment.

  13. wardmundy

    wardmundy Nerd Uno

    You're right. Sorry.
  14. therock112

    therock112 Member

    Can A2billing be installed and configured simply by running a script?

    or does each admin have to go thru the painfull setup process to get this working.....
  15. wardmundy

    wardmundy Nerd Uno

    heh. Now you're learning the true meaning of open $ource, at least to some. :wink5:
  16. sri2talk

    sri2talk New Member

    A2Billing: calling Card Access number does not proceed

    OK. so far everything worked fine. But now, I am not able to dial a DID number from my cell phone to get the calling card prompts.

    Here are the excerpts from the logs:
    -- Executing [s@macro-privacy-mgr:9] GotoIf("SIP/vitel-inbound-b7a0b5a8", "0?fail") in new stack
    -- Executing [s@macro-privacy-mgr:10] SetCallerPres("SIP/vitel-inbound-b7a0b5a8", "allowed_passed_screen") in new stack
    -- Executing [9095555555@from-trunk:6] Goto("SIP/vitel-inbound-b7a0b5a8", " custom-a2billing-2|9095555555|1") in new stack
    -- Goto ( custom-a2billing-2, 9095555555,1)

    [Aug 18 15:27:56] DEBUG[6022] app_macro.c: Executed application: GotoIf
    [Aug 18 15:27:56] VERBOSE[6022] logger.c: -- Executing [s@macro-privacy-mgr:10] SetCallerPres("SIP/vitel-inboun
    d-b7a0b5a8", "allowed_passed_screen") in new stack
    [Aug 18 15:27:56] DEBUG[6022] app_macro.c: Executed application: SetCallerPres
    [Aug 18 15:27:56] VERBOSE[6022] logger.c: -- Executing [9095555555@from-trunk:6] Goto("SIP/vitel-inbound-b7a0b5
    a8", " custom-a2billing-2|9095555555|1") in new stack
    [Aug 18 15:27:56] VERBOSE[6022] logger.c: -- Goto ( custom-a2billing-2, 9095555555,1)
    [Aug 18 15:27:56] WARNING[6022] pbx.c: Channel 'SIP/vitel-inbound-b7a0b5a8' sent into invalid extension '9095555555
    ' in context ' custom-a2billing-2', but no invalid handler
  17. jroper

    jroper Guru


    Short answer, yes it can.

    There is an open source install script included with PiaF for version 1.3.4, and there is are detailed instructions on the A2Billing forum for installing 1.4, as well as an install script modified from my original install script to install 1.4 freely available on the A2Billing forum.

    There is some manual customisation to be done to configure A2Billing itself, but that is to be expected as each person's requirements are different.

    I've not got round to building an install script to install 1.4 for PiaF because of some dependency issues, which require an upgrade to PHP 5.2, more information as to why Centos have not included PHP 5.2 here:-


    NB: I would not advise using the centos testing repository, as it does not yet seem to include php-mcrypt and php-mhash that is required for A2Billing.

    There has also been an issue of time, with a new release, documentation, testing etc, that comes with a new release with so many changes as version 1.4 has over 1.3.4

    Should you get stuck, or need a helping hand, then A2Billing offers commercial support and training through it's website, still being developed at www.star2billing.com. Alternatively, the A2Billing forums provide free support, and I have been known to answer the occasional question on these forums.

    In respect of the question above:-

    sent into invalid extension 9095555555 ' in context ' custom-a2billing-2', but no invalid handler     
    This means that you have sent a call into a context, but no match can be found for the extension number (9095555555)you sent in.

    You should have a context that looks like this :-
      ;For call through service
      exten => _X.,1,Answer()
      exten => _X.,n,Wait(1)
      exten => _X.,n,deadAGI(a2billing.php|2)
      exten => _X.,n,Hangup
    The 9095555555 should match with the _X.

    If your context does not look like this, then obviously alter it, or relax the extension to do a broader match, e.g

       ;For call through service
       exten => _.,1,Answer()
       exten => _.,n,Wait(1)
       exten => _.,n,deadAGI(a2billing.php|2)
       exten => _.,n,Hangup

    I hope this clarifies.


  18. sri2talk

    sri2talk New Member

    The context looks exactly like that.

    I am still getting the same issue. If I change my DID target to A2B-Inbound (custom-a2billing context), the call is answered and "Please enter your PIN" prompt is heard. If I enter the card number it says press 9 to call SIP IAX friend. Upon pressing 9 it dials out as 0119095555555 instead of waiting for me to input the number to call.
    My contexts:
    exten => _X.,1,Answer
    exten => _X.,n,Wait(1)
    exten => _X.,n,deadAGI(a2billing.php|1)
    exten => _X.,n,Hangup
    exten => _.,1,Answer
    exten => _.,n,Wait(1)
    exten => _.,1,deadAGI(a2billing.php|2)
    exten => _.,n,Hangup
    Note: I changed the above based on Joe's suggestion. Same problem.

    Do I need to do anything on the a2billing admin screens? I even entered the DID 9095555555 in the available DIDs section.

    What is missing?

    I am looking for a calling card experience:
    1. Call DID for Calling Card access (e.g. 9095555555)
    2. Answer: "Welcome to My Calling Card" (I need to put this recording and update a2billing.conf).
    3. Caller enters the Card number
    4. Prompt for number to call
    5. Say balance
    6. Call the outgoing number entered
    7. Hangup.
  19. dbenwit

    dbenwit New Member

    Company Directory Problem

    Joe and Ward,

    Thanks for commenting on my company directory problem.

    I should probably clarify that, in the long term, we would like to have our own separate A2Billing server. However, that is not financially possible for us at the moment. That is why we are running A2Billing directly on the customer IP-PBX.

    The workaround at the moment is to disable the company directory in the IVR, however, the customer would like this feature back as soon as possible.

    As I indicated previously, I have isolated the problem to be caused by routing the incoming calls through A2Billing, and that, if I bypass A2Billing, there is no problem. As I have read that this problem may be related to the use of custom feature codes created in Misc. Applications in FreePBX/trixboxCE, I would like to come up with a solution to provide the same functionality, but without having to use the custom feature codes. I am currently trying to think of and test out some alternative solutions. If anyone has any ideas, I would welcome them.

  20. jroper

    jroper Guru


    The # key has a special meaning to Asterisk, can you change the # in FreePBX feature codes to something else, such as a 9, just for testing purposes, so we can see if it is the # key that causes the problem.


Share This Page