Hello Everyone,

I’m currently setting up a system which will allow multiple devices to connect to the same Endpoint through a single AOR. Everything works as expected in terms of registration and calls, however I have an issue with CDR Records.

It seems that whenever calling an internal PJSIP Endpoint (Phone) through the dial string returned by PJSIP_DIAL_CONTACTS, the call is perceived as ‘being offered and outgoing line’ as described in cdr.conf and hence calls to all contacts get recorded as NO ANSWER.

This behaviour makes sense but is problematic in my setup. I assign an AGI generated UUID to each call for external post processing and unique constraint validation on my database fails each time a NO ANSWER record is inserted after the first record is inserted. Moreover I would like to avoid populating the database with unnecessary records or spamming the error logs with constraint validation errors.

Is there a way to mark the call as ‘internal’ despite using PJSIP_DIAL_CONTACTS to achieve the desired behaviour of recording only ANSWERED calls?

Thanks in advance for your kind assistance.


Call Detail Record (CDR) settings

Logging: Enabled
Mode: Simple
Log unanswered calls: No
Log congestion: No


; Desired CDR behaviour.
same => n,Dial(PJSIP/${EXTEN})

; NO ANSWER Records being inserted.
same => n,Dial({PJSIP_DIAL_CONTACTS({EXTEN})})

Are there multiple contacts being dialed? If so then each will produce a CDR, which is how CDRs work.

Yes, however, only one CDR is marked as ANSWERED, ie the contact which actually answers the phone. The other contacts are not answered and these should not be inserted as per the unanswered = no option in cdr.conf.

I may be missing something but my assumption is that asterisk is detecting the call as being ‘offered an outgoing line’ when using the dial string returned by PJSIP_DIAL_CONTACTS.

From cdr.conf;
; Define whether or not to log unanswered calls that don’t involve an outgoing
; party. Setting this to “yes” will make calls to extensions that don’t answer
; and don’t set a B side channel (such as by using the Dial application)
; receive CDR log entries. If this option is set to “no”, then those log
; entries will not be created. Unanswered Calls which get offered to an
; outgoing line will always receive log entries regardless of this option, and
; that is the intended behaviour.
unanswered = no


PJSIP_DIAL_CONTACTS has no influence over that itself, it merely provides a dial string to the Dial() application to dial multiple targets. It would be the behavior of Dial() and what it uses that influences CDRs. I’m not familiar with the finer details of CDRs such as the unanswered option and how it works in combination with Dial().

I think what the documentation is saying is that, if you get an incoming call that is never answered, it won’t get logged, but the moment that you invoke Dial, it becomes eligible for logging, even if not answered.

Asterisk has no concept of an “internal” call. Outgoing is relative to Asterisk, not to your whole site.

My difficulty was the result of lack of understanding how CDR Works. This is the correct answer since my assumption was incorrect and PJSIP_DIAL_CONTACTS is not impacting the creation of CDR Records.

Ive decided to go down a different route. Instead of using CDR to log calls for billing purposes, I’m generating a DB entry independently of CDR using an AGI after Hangup. I wanted to avoid this approach however in my particular case it seems to be the most elegant solution. In a future iteration I will make the DB insert async to avoid slowing down call completion.

CDR will write to CSV and rotate every so often as a backup.

Thank you very much for your assistance.

Following more tests, I can confirm that the behaviour you are describing is also correct. Thank you!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.