Wrong billsec of a new call on an already answered channel

Hi everybody,

What I want to do:
Answer an incoming call and Dial another number. When call is finished I need to have the correct conversation time of the newly made call (which is supposed to be stored in ${CDR(billsec)}).
What I am getting:
Since the channel is answered, the C option in Dial application is only resetting the answer variable of CDR to current time therefore the resulting billsec is equal to duration variable of CDR and is equal to channel seize time not actual call conversation time.
My dial plan:

exten => 333333,1,NoOp(Here I answer the channel and make another call) same => n,Answer same => n,Dial(DAHDI/g0/123456789,,gC) same => n,NoOP(Billsec: ${CDR(billsec)}) // Here billsec is equal to CDR(duration)

Note: If I simply remove Answer CMD from dialplan then billsec variable is showing the correct call time and this makes sense because channel was not answered and CDR(answer) will be assigned as soon as called party answers the channel. But the problem is that in my complete dialplan I have to answer the channel before making the call because I need to interact with user beforehand and it needs the channel to be answered.

BTW, I am using Asterisk 13.0.0-beta1. I have asked the same question on SO and based on the hints received I upgraded to beta2 but the problem persists. I know it is not good to use beta versions for production but unfortunately I am stuck to Asterisk 13 due to a new feature added in this version that my system really depends on it.

Do you guys think it is a bug and I need to submit a bug report on issue tracker or is it that I’m doing something wrong?

You an use ResetCDR. You may also be able to use ForkCDR, but I never understood how that worked.

David, thanks for your reply. I’ve already tried those. C option in Dial application is actually same as ResetCDR. ForkCDR also didn’t solve the problem.

Any heads up guys? I’m going to submit a bug report…

If you have a bug it is in the handling of the C option of Dial, not in the CDR handling. I suggest using ResetCDR explicitly.

Thanks for your suggestions David,
Explicitly using ResetCDR didn’t resolve the problem. I submitted a bug report but support team believes it’s not a bug. Below you can see their response:

[quote=“https://issues.asterisk.org/jira/browse/ASTERISK-24439?filter=-4”]This is not a bug.
The billsec value represents the time from when the channel was Answered to when the CDR was ended. If you explicitly Answer the channel, that starts the time. The ‘C’ options does still reset the CDR, however, CDRs reflect what actually happened to the channel - so the fact that the underlying channel is Answered causes the time to be updated immediately to the time when the Dial is started.
As you noted, the solution here is to not Answer the inbound channel.[/quote]

Someone from SO community suggested using cel (Channel Event Logging) but the problem is that I don’t want to read an extra database for doing my billing operations. I expect to access the conversation time within my dialplan. Any workaround?

Don’t answer the channel or use earlymedia.

In my complete dialplan, user needs to enter a few digits so the dialplan decided on what to do (Make another call, hangup, play a file, etc). Is it possible to do so without answering channel? I don’t think so. I’m currently using Read cmd to get digits pressed by user.

I am pretty sure that the behaviour they say is correct is a regression failure, so, unless there is an UPGRADE.txt entry announcing the change, I think you have a valid bug report.

However, the position used to be that CDRs are not supported for any non-trivial cases.

I have used early media with dtfm with SIP channels and it works, but maybe in his scenario it doesn’t. But as said in the JIRA page thats the expected behavior, when we use an explicit answer then the billsec will start to run.

So maybe the approach is not the best.

I don’t believe it is the behaviour in 1.6.1.0.

Hi Farzan,

I have the same problem.
I need to dial an outgoing number and get the correct conversation time.

Did you find any solution ?

Thanks,

Hi,

I ended up using local channels in asterisk to workaround the issue. Based on the reply that asterisk guys gave me seems that CDR module in asterisk is not supposed to do what I want and what we believe to be a bug or a must-have feature turns out to be their default behavior.
I recommend you to search for local channels and learn how they work. In summary, you first dial a local channel then in your local channel you dial the actual number you want to dial. Here the CDR collected in local channel contains correct billsec of actual outgoing call.

Good luck