Hangup side callee or caller

hi teams,
please help for my dialplan to knowing, which side hangup the call.
i use asterisk 13.16, here is my dialplan:
exten => X!,1,Set(CDR(userfield)=HANGUP_CALLER)
same => n,Dial(SIP/trunk${EXTEN},g)
same => n,Set(CDR(userfield)=${IF($[“${DIALSTATUS}” = “ANSWER”]?HANGUP_CALLEE:HANGUP
DIALSTATUS)})
same => n,hangup

if the caller hangup the call first, cdr looks good. but if the callee hangup the call, the cdr always double.
please enlighten me.

here is the cdr for callee hangup

“”,“1001”,“6541112323”,“out”,“”“”" <1001>",“SIP/1001-0000003a”,“SIP/911-0000003b”,“Dial”,“SIP/1808/6541112323,g”,“2022-10-27 13:29:39”,“2022-10-27 13:29:50”,“2022-10-27 13:29:52”,12,2,“ANSWERED”,“DOCUMENTATION”,“1666852179.89”,“HANGUP_CALLER”

“”,“1001”,“6541112323”,“out”,“”“”" <1001>“,“SIP/1001-0000003a”,”“,“Hangup”,”",“2022-10-27 13:29:52”,“2022-10-27 13:29:52”,“2022-10-27 13:29:52”,0,0,“ANSWERED”,“DOCUMENTATION”,“1666852179.89”,“HANGUP_CALLEE”

Welcome! Did you try it without the ‘g’ option to Dial() ?

Without the g, only calls that failed will reach the code! I believe the OP wants to detect calls that were answered and then hung up by the B side.

I believe the double CDR is expected behaviour after the great CDR rewrite of quite a few years ago.

Agreed! I was addressing the “problem” of double CDRs when that was not really the issue…

To revise my answer and more directly handle OP’s question, I think adding Hangup Handlers via ‘b’ and ‘B’ options to Dial() are probably better ways to go than ‘g’.

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