Problem with CDR while dialing two SIPs

My CDR doesn’t work correctly in the following case:

When I get an incoming call both phones ring (SIP 1001 and SIP 1002). When phone 1002 answers the call, everything is fine with the CDR (dcontext = ANSWERED). But when phone 1001 answers the phone, the CDR dcontext is set with “NO ANSWER” and the CDR callanswer is set “0000-00-00 00:00:00”.

If I change the SIPs

it is just the opposite way. How can I solve this problem? The CDR dcontext should be correctly set as “ANSWERED” - irrespective of which phone answers the call. :neutral_face:

What version of Asterisk? CDRs have drastically changed between 11 and higher versions.

I use Asterisk 13.

12 and above has a CDR specification[1] which documents the resulting CDRs which occur as a result of common scenarios. In this case you’ll end up with two CDR entries. One for the answered leg, one for the unanswered leg. This is expected.

[1] … rallelDial

Thank you so far! I use the Asterisk-package on a Synology Diskstation. This package does not provide an ODBC-connector and it is not possible to install an ODBC-Addon. But I could manage the following workaround to write the CDR into my MariaDB-Database (formerly MySQL):

exten = 01234567,1,NoOp(Incoming call)
exten = 01234567,n,Dial(SIP/1001&[color=#FF0000]SIP/1002[/color],10,t)
exten = h,1,System(mysql --user=DB_USER --password=PASSWORD NAME_DB -e ‘INSERT INTO mycalls (ID, callerid, callstart, callanswer, callend, callstatus) VALUES ("", “${CALLERID(num)}”, “${CDR(start)}”, “${CDR(answer)}”, “${CDR(end)}”, “${CDR(disposition)}”)’)[/quote]

So I realized now, that the CDR-variables (f.e. CDR(disposition)) provide successively the data. Example: a phonecall is coming in --> both phones (SIP 1001 and [color=#FF0000]SIP 1002[/color]) ring --> I pick up phone [color=#FF0000]SIP 1002[/color] --> in a first step CDR(disposition) = NO ANSWER and in the second step CDR(disposition) = [color=#FF0000]ANSWERED[/color] --> when I hang up, my MySQL-command writes the last set CDR(disposition) ("[color=#FF0000]ANSWERED[/color]") into the database.

How (or where in my dialplan) can I “grab” the CDR(disposition) when it is set the first time (in my example “NO ANSWER”)?