Asterisk charges when AGI calls are hangup before answering

I am using Asterisk build and I noticed that when the dialplan goes through AGI and the call is hanged up before being answered at the destination, the call is charged, ie billsec > 0 and the call disposition is marked as ‘ANSWERED’

However if the call is answered billsec is set correctly. eg if the whole call lasted for 20secs, and talk time was 8 secs, duration = 20, billsec = 8

However if the call was hung up before answering billsec is set incorrectly. eg if the whole call lasted for 20secs, duration = 20, billsec = 20 or in some cases billsec=19 (duration - 1)

Whether the dialling itself is done within the AGI, or the AGI drops into the dialplan to allow the call to originate there, the result is the same.

Is this normal Asterisk behaviour, or a bug?

It looks like the $agi->answer() command is treated as a normal call answer, unless the call is answered at the other end, in which the CDR uses the billsecs for that call. Even if I skip the dial in the dialplan and jump to Hangup in the context, it is still treated as ‘ANSWERED’ with duration as 0.


I just posted a similar question to yours as I am experiencing the same problem…well similar.
I used to look at the Master.csv file using a Daemon and my AGI script used to write to the Master.csv so my daemon would pick up the data, but now I am using the AMI, I dont have this flexibility…its a pain !
It woudl be cool if you could output some CDR data from the AGI, but I cant find anything to do that.

So did you find any solution at all?


You need to provide the dialplan. Normally CDRs show the answer time for the incoming side. For non-trivial dialplans, that is normally before any outgoing call is attempted.

More generally, CDRs are known not to be capable of handling non-trivial cases. There is a new call accounting option but it is certainly not in 1.6.x and might only be in the trunk version. It’s called call event logging.

It will never be in 1.4.x.