A2Billing为何不对客户间通话计费?求排查解决方法
Alright, let’s dig into this zero-billing issue for customer-to-customer calls on your A2Billing + Asterisk 13.18-cert3 setup. I’ve troubleshooted similar scenarios before, so here’s a step-by-step breakdown to fix those $0 CDRs:
1. Verify Your LOCAL Carrier’s Matching & Rate Configuration
First, let’s make sure your LOCAL carrier is correctly identifying internal calls and has valid rates attached:
- Head to A2Billing Admin → Carriers → Edit your LOCAL carrier.
- Set a
Match Rulethat catches your internal numbers (e.g.,^(\d{4,7})$for 4-7 digit extensions) so A2Billing recognizes these as local customer calls. - Double-check that the carrier is linked to a Ratecard with non-zero rates for internal calls (even if you want them free, set a 0.0000 rate explicitly—this ensures the billing logic triggers instead of skipping).
- Confirm
Allow IPis enabled and set to your Asterisk server’s IP (or127.0.0.1for local deployments) to trust calls coming from your own system.
- Set a
2. Audit Your Asterisk Trunk & Dialplan
Your Tech=local trunk needs to properly pass call metadata to A2Billing’s AGI:
- In A2Billing’s Trunks settings, ensure the trunk type is set to
LOCALandProvider IPpoints to your Asterisk instance (use127.0.0.1if it’s on the same server). - Check your Asterisk
extensions.confdialplan for internal calls—make sure it calls the A2Billing AGI before connecting the call, so billing is triggered. Example snippet:
[from-internal] exten => _XXXX,1,AGI(a2billing.php,1) ; The "1" here is your A2Billing AGI config ID same => n,Dial(local/${EXTEN},20) same => n,Hangup()
- Verify the AGI config (A2Billing Admin → AGI Configs) linked to that ID has
CDR Enabledturned on andBilling Typeset toPer CallorPer Minuteas needed.
3. Fix CDR Type & Billing Trigger Settings
The two CDR types (DID_Voip and DID-ALEG) might be slipping through the billing cracks:
- Go to A2Billing Admin → System → CDR Management → CDR Import Settings.
- Set
Import CDR TypetoBoth(or explicitly select the two types you’re seeing) to ensure both legs of the call are processed. - Confirm
Billing Triggeris set toAnswer—this ensures billing starts only when the call is answered, which should populate thebillsecfield needed for calculating costs.
- Set
- Check the actual CDRs (A2Billing Admin → CDR → List CDRs) for those zero-cost entries: look for missing
accountcode, emptybillsec, or mismatchedsrc/dstnumbers that aren’t linked to valid customer accounts.
4. Validate Asterisk CDR Data Flow
Asterisk needs to pass accurate call data to A2Billing’s database:
- In the Asterisk CLI, run
cdr show statusto confirm your CDR module (e.g.,cdr_mysqlorcdr_adaptive_odbc) is active and connected to the A2Billing database. - After testing a customer-to-customer call, run
cdr show lastto check ifbillsechas a non-zero value—if it’s 0, Asterisk isn’t detecting the call as answered, which would lead to $0 billing. - Check Asterisk’s CDR logs (
/var/log/asterisk/cdr-csv/Master.csv) to ensure all required fields (accountcode, src, dst, billsec, duration) are populated.
5. Debug with AGI Logs
The A2Billing AGI logs are gold for tracking billing failures:
- Check
/var/log/asterisk/a2billing.logfor entries related to your test calls. Look for errors like:Rate not found: Means the carrier’s match rule isn’t picking up the number, so no rate is applied.Account not found: Theaccountcodepassed from Asterisk doesn’t link to a valid A2Billing customer.
- If you’re using the A2Billing call simulator, make sure you’re using valid customer numbers with active accounts, and check the simulator’s output for any rate-matching errors.
内容的提问来源于stack exchange,提问作者Ali Sarbanha
相关产品推荐
相关产品推荐

