Adding channel to bridge via ARI says channel not in stasis app

I originate a channel by posting to /ari/channels, and I pass query parameter “app=mystasisapp” and “channelId=myChannel0”. I then get a websocket message of type "ChannelCreated" which shows application=mystasisapp. The json response to my post says “app_name:AppDial2” in case that’s relevant. This channel calls the endpoint I specified so that is working great.

I then try to add that channel to my bridge by posting to /ari/bridges/mybridgeid/addChannel, and I pass “channel=myChannel0” (before the call is answered). But the json response to my post says:

General communication error 299 
Channel not in Stasis application

What am I doing wrong? I recall a response in another thread saying a channel originated this way is not added to the stasis app until it is answered. (I think). Does that mean I have to wait until the channel is answered before I can add it to the bridge?

If so, is there another way to originate a channel (create the channel and call an endpoint) and add it to the stasis app (so I can add it to my bridge) even before its answered? (Again I recall something about ‘create’ the channel, but still fuzzy on the difference).

Many thanks…still early on the learning curve, so I apologize if I misuse a term.

Yes, dialling via that method means that until it is answered you can not add it to the bridge.

To add to a bridge before it is answered you would first create a channel using the “/create” channel route, add it to the bridge, and then call “/dial” on it.

Got it. I noticed that /channels function takes a “Caller ID” query parameter which is not available in the /channels/create function. So I assumed that’s it’s provided in the /channels/X/dial command. However, the documentation for /dial says:

Query parameters

  • caller: string - Channel ID of caller

Is that description a mistake? I assumed this should be “caller ID” not “channel ID” of the caller? (since the channel ID is provided in the URL, and caller ID is not accepted as a parameter in either of these functions)

The operation takes a very slimmed down list of arguments in comparison to the origination one; just those required to create an outgoing channel and location information, nothing more. In fact, arguments controlling variables or caller ID are not present, as these should be set using the variable operation before dialing.

Thanks for the article - good overview. Are you sure caller ID needs to be set in a variable if using /dial ? Since channel ID was specified in the /create function, not sure why I would pass that again (and it’s in the URL too)

They are not equivalent. a channel ID is not caller ID. A channel ID is the unique identifier for storing the channel inside of Asterisk and accessing it.

I realize the difference, but something seems odd.

The Channel ID is specified when I create the channel. And when I call /Dial, the Channel Id is specified in the URL.

But, the /create function does NOT accept a Caller ID parameter. Which makes me think it should be passed at the time of /Dial. The doc also calls this parameter “caller” (not channel ID) which disagrees with the description.

I thought maybe I found an error, but I’ll play with it!

You use variables in the /create function to set such information. The example in docs even shows setting callerid[1]. The channel ID has to be passed as part of the URL so that ARI knows what channel it should dial.

[1] Channels - Asterisk Documentation

Ok, I’ll pass the channel ID as a query parameter. This may seem stupid, but, is that the same as the channelId in the url:

POST /channels/{channelId}/dial

So I’m using the same channelId in the URL and as a query parameter? The doc calls the query parameter the “channel ID of the caller”. Since I’m initiating the call from the PBX to endpoint,I’m not sure what the caller is, but since I have only created one channel at this point I’m guessing it’s the same thing.

Channel ID is an arbitrary unique identifier only used within Asterisk itself for identifying the channel within Asterisk and exists in events, CDRs, CEL, and ARI. You’re giving it far greater meaning than it has. It’s not exposed outside of Asterisk.

Asterisk normally generates one for you on every channel.

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