Channel not in Stasis Application While answering Channel

Hi Everyone,

Am trying to answer call with ARI API(/channel/answer) but it throwing error like channel not in stasis application .
Could anyone help me to fix this one and i am following ARI Tester html library as mentioned in asterisk ari document.
Could anyone provide full video about how to configure asterisk and in which order we have to use those buttons in that project

There is no team here. This is a public community forum.

If you are using outside libraries or instructions or a document, then providing links to it can reduce the amount of effort people have to go through to help.

The message means what it means though, you can’t call answer on a channel that is not in your ARI application.

Could anyone offer some guidance on how to set up the channel within an ARI application? I’ve been exploring the aritester GitHub project referenced in the Asterisk documentation here
Thank you in advance!

You can use the Stasis application. This will suspend the channel and send an event via a WebSocket connection to an ARI listener.

But beginning from Asterisk 16.3, the ability was added to create channels entirely from thin air in ARI, without the need for any dialplan configuration at all.

I’ve been working on creating a channel within ARI using javscript (Reference from ARITESTER), but I keep encountering an error. I wanted to double-check the steps I’m following and see if anyone could point out any mistakes:

  1. Creating the channel
  2. Adding the channel to a bridge
  3. Dialing the channel
  4. Answering the channel

However, when I try to answer the channel, I’m getting an error saying “channel not in Stasis application”. If anyone has any insights or suggestions on what might be going wrong here.

I’ve observed that the ‘StasisStart’ event is triggered after answering a channel from another client application. However, I understand that it should ideally be raised when the channel state transitions to ‘ringing’ or upon creation of channel. Can anyone provide guidance on how to ensure this event is appropriately triggered in accordance with the channel’s state change?

Well, you can’t answer a dialled outgoing channel for one thing. That’s the equivalent of you picking up a phone, dialling a person, and then forcing the phone (them) on the other end to pick up.

Otherwise you have to actually show the specific requests you are making, the events, and the Asterisk console output. General descriptions result in us guessing/assuming what you are doing and what is going on - which is often incorrect, and then wastes time.

Please find below the log I am currently observing.

  • Connected
  • POST http://192.168.180.118:8088/ari/applications/hello-world/subscription?eventSource=channel:,endpoint:,bridge:,deviceState:
  • 200 OK{ “name”: “hello-world”, “channel_ids”: [ “__AST_CHANNEL_ALL_TOPIC” ], “bridge_ids”: [ “__AST_BRIDGE_ALL_TOPIC” ], “endpoint_ids”: [ “__AST_ENDPOINT_ALL_TOPIC” ], “device_names”: [ “__AST_DEVICE_STATE_ALL_TOPIC” ], “events_allowed”: , “events_disallowed”: }
  • POST http://192.168.180.118:8088/ari/channels/create?endpoint=pjsip/167&app=hello-world&channelId=106
  • { “type”: “ChannelCreated”, “timestamp”: “2024-04-12T17:00:38.628+0530”, “channel”: { “id”: “106”, “name”: “PJSIP/167-00000007”, “state”: “Down”, “protocol_id”: “”, “caller”: { “name”: “linuxhelp”, “number”: “167” }, “connected”: { “name”: “”, “number”: “” }, “accountcode”: “”, “dialplan”: { “context”: “internal”, “exten”: “s”, “priority”: 1, “app_name”: “”, “app_data”: “” }, “creationtime”: “2024-04-12T17:00:38.628+0530”, “language”: “en” }, “asterisk_id”: “08:2e:5f:31:e4:15”, “application”: “hello-world” }
  • { “type”: “ChannelDialplan”, “timestamp”: “2024-04-12T17:00:38.629+0530”, “dialplan_app”: “Stasis”, “dialplan_app_data”: “hello-world”, “channel”: { “id”: “106”, “name”: “PJSIP/167-00000007”, “state”: “Down”, “protocol_id”: “dd53ebb6-4afa-4053-8c5d-083dc16f6116”, “caller”: { “name”: “linuxhelp”, “number”: “167” }, “connected”: { “name”: “”, “number”: “” }, “accountcode”: “”, “dialplan”: { “context”: “internal”, “exten”: “s”, “priority”: 1, “app_name”: “Stasis”, “app_data”: “hello-world” }, “creationtime”: “2024-04-12T17:00:38.628+0530”, “language”: “en” }, “asterisk_id”: “08:2e:5f:31:e4:15”, “application”: “hello-world” }
  • 200 OK{ “id”: “106”, “name”: “PJSIP/167-00000007”, “state”: “Down”, “protocol_id”: “dd53ebb6-4afa-4053-8c5d-083dc16f6116”, “caller”: { “name”: “linuxhelp”, “number”: “167” }, “connected”: { “name”: “”, “number”: “” }, “accountcode”: “”, “dialplan”: { “context”: “internal”, “exten”: “s”, “priority”: 1, “app_name”: “”, “app_data”: “” }, “creationtime”: “2024-04-12T17:00:38.628+0530”, “language”: “en” }
  • { “variable”: “STASISSTATUS”, “value”: “”, “type”: “ChannelVarset”, “timestamp”: “2024-04-12T17:00:38.629+0530”, “channel”: { “id”: “106”, “name”: “PJSIP/167-00000007”, “state”: “Down”, “protocol_id”: “dd53ebb6-4afa-4053-8c5d-083dc16f6116”, “caller”: { “name”: “linuxhelp”, “number”: “167” }, “connected”: { “name”: “”, “number”: “” }, “accountcode”: “”, “dialplan”: { “context”: “internal”, “exten”: “s”, “priority”: 1, “app_name”: “Stasis”, “app_data”: “hello-world” }, “creationtime”: “2024-04-12T17:00:38.628+0530”, “language”: “en” }, “asterisk_id”: “08:2e:5f:31:e4:15”, “application”: “hello-world” }
  • { “type”: “StasisStart”, “timestamp”: “2024-04-12T17:00:38.629+0530”, “args”: , “channel”: { “id”: “106”, “name”: “PJSIP/167-00000007”, “state”: “Down”, “protocol_id”: “dd53ebb6-4afa-4053-8c5d-083dc16f6116”, “caller”: { “name”: “linuxhelp”, “number”: “167” }, “connected”: { “name”: “”, “number”: “” }, “accountcode”: “”, “dialplan”: { “context”: “internal”, “exten”: “s”, “priority”: 1, “app_name”: “Stasis”, “app_data”: “hello-world” }, “creationtime”: “2024-04-12T17:00:38.628+0530”, “language”: “en” }, “asterisk_id”: “08:2e:5f:31:e4:15”, “application”: “hello-world” }
  • POST http://192.168.180.118:8088/ari/bridges?type=mixing
  • { “type”: “BridgeCreated”, “timestamp”: “2024-04-12T17:00:42.666+0530”, “bridge”: { “id”: “3c22916a-8371-416e-bdef-132c3ac89982”, “technology”: “simple_bridge”, “bridge_type”: “mixing”, “bridge_class”: “stasis”, “creator”: “Stasis”, “name”: “”, “channels”: , “creationtime”: “2024-04-12T17:00:42.666+0530”, “video_mode”: “talker” }, “asterisk_id”: “08:2e:5f:31:e4:15”, “application”: “hello-world” }
  • 200 OK{ “id”: “3c22916a-8371-416e-bdef-132c3ac89982”, “technology”: “simple_bridge”, “bridge_type”: “mixing”, “bridge_class”: “stasis”, “creator”: “Stasis”, “name”: “”, “channels”: , “creationtime”: “2024-04-12T17:00:42.666+0530”, “video_mode”: “talker” }
  • POST http://192.168.180.118:8088/ari/bridges/3c22916a-8371-416e-bdef-132c3ac89982/addChannel?channel=106&role=partecipant
  • { “type”: “ChannelEnteredBridge”, “timestamp”: “2024-04-12T17:00:46.359+0530”, “bridge”: { “id”: “3c22916a-8371-416e-bdef-132c3ac89982”, “technology”: “simple_bridge”, “bridge_type”: “mixing”, “bridge_class”: “stasis”, “creator”: “Stasis”, “name”: “”, “channels”: [ “106” ], “creationtime”: “2024-04-12T17:00:42.666+0530”, “video_mode”: “talker” }, “channel”: { “id”: “106”, “name”: “PJSIP/167-00000007”, “state”: “Down”, “protocol_id”: “dd53ebb6-4afa-4053-8c5d-083dc16f6116”, “caller”: { “name”: “linuxhelp”, “number”: “167” }, “connected”: { “name”: “”, “number”: “” }, “accountcode”: “”, “dialplan”: { “context”: “internal”, “exten”: “s”, “priority”: 1, “app_name”: “Stasis”, “app_data”: “hello-world” }, “creationtime”: “2024-04-12T17:00:38.628+0530”, “language”: “en” }, “asterisk_id”: “08:2e:5f:31:e4:15”, “application”: “hello-world” }
  • 204 No Content
  • POST http://192.168.180.118:8088/ari/channels?endpoint=pjsip/167&extension=167&context=default&callerId=pjsip/167
  • { “type”: “ChannelCreated”, “timestamp”: “2024-04-12T17:00:49.304+0530”, “channel”: { “id”: “1712921449.9”, “name”: “PJSIP/167-00000008”, “state”: “Down”, “protocol_id”: “”, “caller”: { “name”: “linuxhelp”, “number”: “167” }, “connected”: { “name”: “”, “number”: “” }, “accountcode”: “”, “dialplan”: { “context”: “internal”, “exten”: “s”, “priority”: 1, “app_name”: “”, “app_data”: “” }, “creationtime”: “2024-04-12T17:00:49.304+0530”, “language”: “en” }, “asterisk_id”: “08:2e:5f:31:e4:15”, “application”: “hello-world” }
  • { “type”: “ChannelDialplan”, “timestamp”: “2024-04-12T17:00:49.304+0530”, “dialplan_app”: “AppDial2”, “dialplan_app_data”: “(Outgoing Line)”, “channel”: { “id”: “1712921449.9”, “name”: “PJSIP/167-00000008”, “state”: “Down”, “protocol_id”: “d64c587d-e81f-46a5-b241-a0f6e7e6c408”, “caller”: { “name”: “linuxhelp”, “number”: “167” }, “connected”: { “name”: “”, “number”: “” }, “accountcode”: “”, “dialplan”: { “context”: “internal”, “exten”: “s”, “priority”: 1, “app_name”: “AppDial2”, “app_data”: “(Outgoing Line)” }, “creationtime”: “2024-04-12T17:00:49.304+0530”, “language”: “en” }, “asterisk_id”: “08:2e:5f:31:e4:15”, “application”: “hello-world” }
  • { “type”: “ChannelCallerId”, “timestamp”: “2024-04-12T17:00:49.304+0530”, “caller_presentation”: 0, “caller_presentation_txt”: “Presentation Allowed, Not Screened”, “channel”: { “id”: “1712921449.9”, “name”: “PJSIP/167-00000008”, “state”: “Down”, “protocol_id”: “d64c587d-e81f-46a5-b241-a0f6e7e6c408”, “caller”: { “name”: “pjsip/167”, “number”: “167” }, “connected”: { “name”: “”, “number”: “” }, “accountcode”: “”, “dialplan”: { “context”: “internal”, “exten”: “s”, “priority”: 1, “app_name”: “AppDial2”, “app_data”: “(Outgoing Line)” }, “creationtime”: “2024-04-12T17:00:49.304+0530”, “language”: “en” }, “asterisk_id”: “08:2e:5f:31:e4:15”, “application”: “hello-world” }
  • { “type”: “ChannelConnectedLine”, “timestamp”: “2024-04-12T17:00:49.304+0530”, “channel”: { “id”: “1712921449.9”, “name”: “PJSIP/167-00000008”, “state”: “Down”, “protocol_id”: “d64c587d-e81f-46a5-b241-a0f6e7e6c408”, “caller”: { “name”: “pjsip/167”, “number”: “167” }, “connected”: { “name”: “pjsip/167”, “number”: “” }, “accountcode”: “”, “dialplan”: { “context”: “internal”, “exten”: “s”, “priority”: 1, “app_name”: “AppDial2”, “app_data”: “(Outgoing Line)” }, “creationtime”: “2024-04-12T17:00:49.304+0530”, “language”: “en” }, “asterisk_id”: “08:2e:5f:31:e4:15”, “application”: “hello-world” }
  • { “type”: “Dial”, “timestamp”: “2024-04-12T17:00:49.304+0530”, “dialstatus”: “”, “forward”: “”, “dialstring”: “167”, “peer”: { “id”: “1712921449.9”, “name”: “PJSIP/167-00000008”, “state”: “Down”, “protocol_id”: “d64c587d-e81f-46a5-b241-a0f6e7e6c408”, “caller”: { “name”: “pjsip/167”, “number”: “167” }, “connected”: { “name”: “pjsip/167”, “number”: “” }, “accountcode”: “”, “dialplan”: { “context”: “internal”, “exten”: “s”, “priority”: 1, “app_name”: “AppDial2”, “app_data”: “(Outgoing Line)” }, “creationtime”: “2024-04-12T17:00:49.304+0530”, “language”: “en” }, “asterisk_id”: “08:2e:5f:31:e4:15”, “application”: “hello-world” }
  • 200 OK{ “id”: “1712921449.9”, “name”: “PJSIP/167-00000008”, “state”: “Down”, “protocol_id”: “d64c587d-e81f-46a5-b241-a0f6e7e6c408”, “caller”: { “name”: “pjsip/167”, “number”: “167” }, “connected”: { “name”: “pjsip/167”, “number”: “” }, “accountcode”: “”, “dialplan”: { “context”: “internal”, “exten”: “s”, “priority”: 1, “app_name”: “AppDial2”, “app_data”: “(Outgoing Line)” }, “creationtime”: “2024-04-12T17:00:49.304+0530”, “language”: “en” }
  • { “type”: “ChannelStateChange”, “timestamp”: “2024-04-12T17:00:49.777+0530”, “channel”: { “id”: “1712921449.9”, “name”: “PJSIP/167-00000008”, “state”: “Ringing”, “protocol_id”: “d64c587d-e81f-46a5-b241-a0f6e7e6c408”, “caller”: { “name”: “pjsip/167”, “number”: “167” }, “connected”: { “name”: “pjsip/167”, “number”: “” }, “accountcode”: “”, “dialplan”: { “context”: “internal”, “exten”: “s”, “priority”: 1, “app_name”: “AppDial2”, “app_data”: “(Outgoing Line)” }, “creationtime”: “2024-04-12T17:00:49.304+0530”, “language”: “en” }, “asterisk_id”: “08:2e:5f:31:e4:15”, “application”: “hello-world” }
  • { “type”: “DeviceStateChanged”, “application”: “hello-world”, “timestamp”: “2024-04-12T17:00:49.777+0530”, “device_state”: { “name”: “PJSIP/167”, “state”: “RINGING” }, “asterisk_id”: “08:2e:5f:31:e4:15” }
  • { “type”: “Dial”, “timestamp”: “2024-04-12T17:00:49.777+0530”, “dialstatus”: “RINGING”, “forward”: “”, “dialstring”: “167”, “peer”: { “id”: “1712921449.9”, “name”: “PJSIP/167-00000008”, “state”: “Ringing”, “protocol_id”: “d64c587d-e81f-46a5-b241-a0f6e7e6c408”, “caller”: { “name”: “pjsip/167”, “number”: “167” }, “connected”: { “name”: “pjsip/167”, “number”: “” }, “accountcode”: “”, “dialplan”: { “context”: “internal”, “exten”: “s”, “priority”: 1, “app_name”: “AppDial2”, “app_data”: “(Outgoing Line)” }, “creationtime”: “2024-04-12T17:00:49.304+0530”, “language”: “en” }, “asterisk_id”: “08:2e:5f:31:e4:15”, “application”: “hello-world” }
  • POST http://192.168.180.118:8088/ari/channels/1712921449.9/answer
  • 409 Conflict{ “message”: “Channel not in Stasis application” }
POST http://192.168.180.118:8088/ari/channels?endpoint=pjsip/167&extension=167&context=default&callerId=pjsip/167

You are originating a call to “pjsip/167” and upon answer sending it into the dialplan at extension “167” and context “default”. The channel is not in ARI/Stasis, so the response from answer is correct. Additionally it is an outgoing call so calling answer on it would have no effect even if it were in ARI/Stasis.

I have examples (in Python) in my seaskirt_examples repo: track_call_ari_async uses a promiscuous ARI event listener without bridging, and track_call_ari_bridged_async defines a specific ARI “application” for events, and uses a bridge.

The flow of control for the bridged version is

  • Create the channels for the two ends of the call
  • Record the respective channel IDs when I received the corresponding “channel created” events
  • As I received the “stasis start” event for each channel, add it to the bridge
  • Wait for a “channel destroyed” event to indicate the end of the call;
  • Tear down any channels still attached to my bridge
  • Tear down my bridge.

As you can see, this is all done without any dialplan setup at all.