ARI: Getting channel events after calling /channels/{channelId}/continue

I’m building a Stasis app that originates outbound calls and I’m running into an issue where I’m still getting channel events after calling /channels/{channelId}/continue.

My basic application flow is:

  • Originate a call by making a POST to /channels
  • Do some work in the app
  • Hand back to the dialplan to continue the call in other apps by calling /channels/{channelId}/continue

This is working. After I call /channels/{channelId}/continue I see a "type"=>"StasisEnd" message come through. However, my app does not stop receiving events for the channel.

Here are some relevant lines from my app logs that show:

  • The call to /channels/{channelId}/continue getting a 204
  • A StasisEnd message coming into my app
  • A NoOp in the dialplan exten the channel was sent to triggering events into my app
D, [2024-02-20T07:32:55.790369 #1] DEBUG -- Asterisk::ARIClient(dialin_bridge_asterisk:8088): rest: HTTP post request to http://dialin_bridge_asterisk:8088/ari/channels/1708414369.34.dialin_bridge_callout.0cc0c966652307ccd538c649822e51d1/continue?context=dialin_bridge_internal_enter&extension=s&priority=1 returned 204

D, [2024-02-20T07:32:55.791194 #1] DEBUG -- Asterisk::ARIClient(dialin_bridge_asterisk:8088): WS: Processing {"type":"StasisEnd","timestamp":"2024-02-20T02:32:55.790-0500","channel":{"id":"1708414369.34.dialin_bridge_callout.0cc0c966652307ccd538c649822e51d1","name":"IAX2/primary_internal-23673","state":"Up","protocol_id":"","caller":{"name":"","number":""},"connected":{"name":"","number":""},"accountcode":"","dialplan":{"context":"dialin_bridge_private_extens","exten":"s","priority":1,"app_name":"Stasis","app_data":"dialin_bridge_callout_handler"},"creationtime":"2024-02-20T02:32:49.136-0500","language":"en"},"asterisk_id":"02:42:ac:11:00:0b","application":"dialin_bridge_callout_handler"}

D, [2024-02-20T07:32:55.791764 #1] DEBUG -- Asterisk::ARIClient(dialin_bridge_asterisk:8088): WS: Processing {"type":"ChannelDialplan","timestamp":"2024-02-20T02:32:55.790-0500","dialplan_app":"NoOp","dialplan_app_data":"\"Jumping back to primary\"","channel":{"id":"1708414369.34.dialin_bridge_callout.0cc0c966652307ccd538c649822e51d1","name":"IAX2/primary_internal-23673","state":"Up","protocol_id":"","caller":{"name":"","number":""},"connected":{"name":"","number":""},"accountcode":"","dialplan":{"context":"dialin_bridge_internal_enter","exten":"s","priority":1,"app_name":"NoOp","app_data":"\"Dialin Bridge: Internal callee entering conference: Jumping back to primary\""},"creationtime":"2024-02-20T02:32:49.136-0500","language":"en"},"asterisk_id":"02:42:ac:11:00:0b","application":"dialin_bridge_callout_handler"}

The stream of events after my app is supposed to be completed is causing issues as the message structure changes depending on how the event is generated, which is triggering error handlers. I read the POST /channels/{channelId}/continue of Exit application; continue execution in the dialplan. as “My app is done and will no longer be sent events for this channel”, which is the behavior I want. Is there another API I need to call to unsubscribe from the channel?

Calling continue in most cases will cease events, but that is because it leaves the Stasis() dialplan application. If you have originated a channel that goes to a Stasis app then you may have two subscriptions to the channel (one from originate, one from going to the app). You can use the unsubscribe route[1] to unsubscribe from the channel and see if that works.

[1] Applications - Asterisk Documentation

Thanks. I had a feeling it was something like this due to originating the call in the app, but didn’t realize the answer was in the /applications endpoint.

One thing I did notice was that I had to unsubscribe, then continue. Once I did that the stray events stopped.

Thanks!

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