# CDR fields empty and Hangup fired from AudioSocket channel when call routed to Stasis app

**URL:** <https://community.asterisk.org/t/cdr-fields-empty-and-hangup-fired-from-audiosocket-channel-when-call-routed-to-stasis-app/112245>\
**Category:** Asterisk APIs\
**Created:** [March 10, 2026, 2:15pm UTC](https://community.asterisk.org/t/cdr-fields-empty-and-hangup-fired-from-audiosocket-channel-when-call-routed-to-stasis-app/112245 "2026-03-10T14:15:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abiboba1](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/abiboba1/32/9936_2.png) [@Abiboba1](https://community.asterisk.org/u/Abiboba1)\
**Post date:** [March 10, 2026, 2:15pm UTC](https://community.asterisk.org/t/cdr-fields-empty-and-hangup-fired-from-audiosocket-channel-when-call-routed-to-stasis-app/112245/1 "2026-03-10T14:15:38Z")

</div>

Hi, we’re running Asterisk 20(via MikoPBX) with a Stasis application connected via AudioSocket. When a call is routed into Stasis, the final AMI Hangup event comes from the AudioSocket channel instead of the original PJSIP channel — and as a result, CDR fields are empty.

Normal call (internal → internal), SQLite CDR:

src\_chan = PJSIP/554-00000003

dst\_chan = PJSIP/666-00000004

to\_account = 666

dialstatus = ANSWERED

Call routed to Stasis (both internal and external), SQ Lite CDR:

src\_chan = PJSIP/554-00000006

dst\_chan = (empty)

to\_account = (empty)

dialstatus = (empty)

dst\_num = 123 ← this is filled

AMI Hangup — normal call:

Channel: PJSIP/554-00000003

CallerIDNum: 554

ConnectedLineNum: 666

CDR(lastapp)=Dial

CDR(src)=554

CDR(dst)=666

AMI Hangup — Stasis call:

Channel: AudioSocket/ 127.0.0.1:8090-b58fcafb-. ..

CallerIDNum:

ConnectedLineNum: 554

CDR(lastapp)=Stasis

CDR(src)=

CDR(dst)=s

Current dialplan:

exten =\> 123,1,NoOp(User calling AI)

same =\> n,Answer()

same =\> n,Set(CONNECTEDLINE(num)=ai\_agent)

same =\> n,Gosub(dial\_answer,s,1)

same =\> n,Stasis(asterisk-ai-voice-agent)

same =\> n,Hangup()

Questions:

1. Is this expected Asterisk behavior when routing to Stasis — that the final Hangup comes fro m the AudioSocket channel rather than PJSIP?

2. Is there any way to influence which channel generates the final Hangup event?

3. Is there a dialplan-level workaround to properly populate `dst_chan` , `CDR(src)`, `CDR(dst)` for Stasis scenarios?

We tried setting CDR variables and firing a UserEvent before Stasis — the UserEvent appeared in AMI with correct data, but the final Hangup still comes from AudioSocket with empty fields.

Thanks!

---

<div class="post-metadata">

**Author:** ![jcolp](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/jcolp/32/8848_2.png) [@jcolp](https://community.asterisk.org/u/jcolp)\
**Post date:** [March 10, 2026, 2:19pm UTC](https://community.asterisk.org/t/cdr-fields-empty-and-hangup-fired-from-audiosocket-channel-when-call-routed-to-stasis-app/112245/2 "2026-03-10T14:19:11Z")

</div>

> [@Abiboba1](#):
>
> 1. Is this expected Asterisk behavior when routing to Stasis — that the final Hangup comes fro m the AudioSocket channel rather than PJSIP?

When something is hung up it generates the event, so if both channels are hung up then there would be two events. It depends what has happened to the channels.

You haven’t stated what actually happens in ARI, how channels are controlled, etc, which are important when it comes to ARI applications to be able to answer questions.

---

<div class="post-metadata">

**Author:** ![Abiboba1](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/abiboba1/32/9936_2.png) [@Abiboba1](https://community.asterisk.org/u/Abiboba1)\
**Post date:** [March 10, 2026, 2:34pm UTC](https://community.asterisk.org/t/cdr-fields-empty-and-hangup-fired-from-audiosocket-channel-when-call-routed-to-stasis-app/112245/3 "2026-03-10T14:34:03Z")

</div>

Thanks for the reply!

To be honest, we don’t have full visibility into the ARI application internals — it’s a third-party AI voice agent. What we can observe from the outside:

— The original PJSIP channel receives the call — The Stasis app creates an AudioSocket channel (127.0.0.1:8090) — We do see two Hangup events: one from the original PJSIP channel, and one from AudioSocket — The PJSIP Hangup fires first and contains correct CDR data — The AudioSocket Hangup fires last with empty CDR fields

Our integrations (third-party 1C CRM connectors) appear to pick up the last Hangup event, which is AudioSocket — and that’s where the problem lies.

Is there a way to ensure the PJSIP channel’s Hangup is the one that carries complete CDR data, regardless of what the ARI app does internally? Or is the CDR outcome entirely determined by the ARI application’s channel handling?

---

<div class="post-metadata">

**Author:** ![jcolp](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/jcolp/32/8848_2.png) [@jcolp](https://community.asterisk.org/u/jcolp)\
**Post date:** [March 10, 2026, 2:36pm UTC](https://community.asterisk.org/t/cdr-fields-empty-and-hangup-fired-from-audiosocket-channel-when-call-routed-to-stasis-app/112245/4 "2026-03-10T14:36:23Z")

</div>

What the ARI application does controls CDR things, and you can’t guarantee ordering either.

---

<div class="post-metadata">

**Author:** ![Abiboba1](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/abiboba1/32/9936_2.png) [@Abiboba1](https://community.asterisk.org/u/Abiboba1)\
**Post date:** [March 10, 2026, 2:53pm UTC](https://community.asterisk.org/t/cdr-fields-empty-and-hangup-fired-from-audiosocket-channel-when-call-routed-to-stasis-app/112245/5 "2026-03-10T14:53:26Z")

</div>

Thank you, this really helped!

Just to make sure I understood correctly :

The CDR fields (src, dst, channel) are controlled by what the ARI application does with its channels internally. In our case the Stasis app creates an AudioSocket channel for the actual conversation — that’s by design, since it’s a realtime AI voice agent. The final Hangup comes from that AudioSocket channel with empty CDR fields, and there’s no way to change that from the dialplan side without modifying the ARI application itse lf.

Ordering of Hangup events is also not guaranteed, so relying on event order is not a viable approach either.

Thanks again!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/asterisk/original/2X/4/475d0c889911cfb84ac4881ad6df8b523e3f9105.png) [@system](https://community.asterisk.org/u/system)\
**Post date:** [April 9, 2026, 2:54pm UTC](https://community.asterisk.org/t/cdr-fields-empty-and-hangup-fired-from-audiosocket-channel-when-call-routed-to-stasis-app/112245/6 "2026-04-09T14:54:00Z")

</div>

Closed on April 9, 2026, 2:54pm UTC

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