Failed to add channel in bridge using Asterisk ARI

Hi everyone,

I’m working on a VoIP application using Asterisk ARI and facing an issue while patching two calls (one incoming and one outbound) using the bridge functionality (mixing mode).

Here’s the process I’m following:

  • I’m using the ARI API to create a bridge. This step is successful, and I receive a bridge ID.
  • Next, I use the addChannel API of the bridge to add both channels individually into the bridge. The request body contains the ARI channel ID.
  • However, I keep getting a 400 response from the addChannel API. I’ve tried using the channel name, but the result is the same.

Here is the body of my addChannel POST request:

{
“channel”: “ariChannelId”,
“role”: “participant”,
“absorbDTMF”: false,
“mute”: false,
“inhibitConnectedLineUpdates”: false
}

Docs ref: Bridges - Asterisk Documentation

I also tried following body for addChannel but the result is the same 400 response code.

{
“channel”: “ariChannelId”
}

I’ve checked the Asterisk debug logs but only see some ARI endpoint pattern matching logs followed by the 400 response log without any root cause message for addChannel failure.

Here are some details of my setup:

Asterisk version: 18.8.0
OS: CentOS

Any advice on what might be causing this issue or how to further debug it would be greatly appreciated. Has anyone encountered similar problems or can provide insights into what might be going wrong?

Thanks in advance for your help!

Below are asterisk DEBUG logs for reference:

[May 16 14:08:00] DEBUG[22209] stasis.c: Creating topic. name: bridge:all/bridge:d0b8f93228cf41fbb596306fc913750e, detail:
[May 16 14:08:00] DEBUG[22209] stasis.c: Topic ‘bridge:all/bridge:d0b8f93228cf41fbb596306fc913750e’: 0x7f4fac003a20 created
[May 16 14:08:00] DEBUG[22125][C-0000006e] res_rtp_asterisk.c: (0x7f4f80008180) RTP no remote address on instance, so dropping frame
[May 16 14:08:00] DEBUG[22209] bridge_native_rtp.c: Bridge ‘d0b8f93228cf41fbb596306fc913750e’ can not use native RTP bridge as two channels are required
[May 16 14:08:00] DEBUG[22209] bridge.c: Bridge technology native_rtp is not compatible with properties of existing bridge.
[May 16 14:08:00] DEBUG[22125][C-0000006e] res_rtp_asterisk.c: (0x7f4f80008180) RTP no remote address on instance, so dropping frame
[May 16 14:08:00] DEBUG[22125][C-0000006e] res_rtp_asterisk.c: (0x7f4f80008180) RTP no remote address on instance, so dropping frame
[May 16 14:08:00] DEBUG[22209] dahdi/bridge_native_dahdi.c: Bridge d0b8f93228cf41fbb596306fc913750e: Cannot use native DAHDI. Must have two channels.
[May 16 14:08:00] DEBUG[22209] bridge.c: Bridge technology native_dahdi is not compatible with properties of existing bridge.
[May 16 14:08:00] DEBUG[22125][C-0000006e] res_rtp_asterisk.c: (0x7f4f80008180) RTP no remote address on instance, so dropping frame
[May 16 14:08:00] DEBUG[22209] bridge.c: Bridge technology holding_bridge does not have any capabilities we want.
[May 16 14:08:00] VERBOSE[22174] res_rtp_asterisk.c: 0x7f4f8002e540 – Strict RTP switching to RTP target address IP:PORT as source
[May 16 14:08:00] DEBUG[22174] chan_pjsip.c: Oooh, got a frame with format of ulaw on channel ‘PJSIP/devtest-0000008b’ when we’re sending ‘alaw’, switching to match
[May 16 14:08:00] DEBUG[22174] channel_internal_api.c: PJSIP/devtest-0000008b: MultistreamFormats: (ulaw)
[May 16 14:08:00] DEBUG[22174] channel_internal_api.c: Set native formats but not topology
[May 16 14:08:00] DEBUG[22174] channel.c: Channel PJSIP/devtest-0000008b setting write format path: ulaw → ulaw
[May 16 14:08:00] DEBUG[22174] channel.c: Channel PJSIP/devtest-0000008b setting read format path: ulaw → ulaw
[May 16 14:08:00] DEBUG[22209] bridge.c: Bridge technology softmix has less preference than simple_bridge (10 <= 50). Skipping.
[May 16 14:08:00] DEBUG[22209] bridge.c: Chose bridge technology simple_bridge
[May 16 14:08:00] DEBUG[22209] bridge.c: Bridge d0b8f93228cf41fbb596306fc913750e: calling simple_bridge technology constructor
[May 16 14:08:00] DEBUG[22209] bridge.c: Bridge d0b8f93228cf41fbb596306fc913750e: calling simple_bridge technology start
[May 16 14:08:00] DEBUG[22209] stasis_bridges.c: Update: 0x7f4fac004638 Old: New: d0b8f93228cf41fbb596306fc913750e
[May 16 14:08:00] DEBUG[22209] stasis_bridges.c: Update: 0x7f4fac004638 Old: New: d0b8f93228cf41fbb596306fc913750e
[May 16 14:08:00] DEBUG[22209] http.c: HTTP keeping session open. status_code:200
[May 16 14:08:00] DEBUG[22209] http.c: HTTP Request URI is /ari/channels
[May 16 14:08:00] DEBUG[22209] http.c: match request [ari/channels] with handler [httpstatus] len 10
[May 16 14:08:00] DEBUG[22209] http.c: match request [ari/channels] with handler [phoneprov] len 9
[May 16 14:08:00] DEBUG[22209] http.c: match request [ari/channels] with handler [metrics] len 7
[May 16 14:08:00] DEBUG[22209] http.c: match request [ari/channels] with handler [static] len 6
[May 16 14:08:00] DEBUG[22209] http.c: match request [ari/channels] with handler [ari] len 3
[May 16 14:08:00] DEBUG[22209] http.c: Match made with [ari]
[May 16 14:08:00] DEBUG[22209] res_ari.c: Finding handler for channels
[May 16 14:08:00] DEBUG[22209] res_ari.c: Finding handler for channels
[May 16 14:08:00] DEBUG[22209] res_ari.c: Checking ari bridges: Didn’t match channels
[May 16 14:08:00] DEBUG[22209] res_ari.c: Checking ari applications: Didn’t match channels
[May 16 14:08:00] DEBUG[22209] res_ari.c: Checking ari events: Didn’t match channels
[May 16 14:08:00] DEBUG[22209] res_ari.c: Checking ari recordings: Didn’t match channels
[May 16 14:08:00] DEBUG[22209] res_ari.c: Checking ari playbacks: Didn’t match channels
[May 16 14:08:00] DEBUG[22209] res_ari.c: Checking ari endpoints: Didn’t match channels
[May 16 14:08:00] DEBUG[22209] res_ari.c: Checking ari sounds: Didn’t match channels
[May 16 14:08:00] DEBUG[22209] res_ari.c: Checking ari asterisk: Didn’t match channels
[May 16 14:08:00] DEBUG[22209] res_ari.c: Checking ari deviceStates: Didn’t match channels
[May 16 14:08:00] DEBUG[22209] res_ari.c: Checking ari channels: Explicit match with channels
[May 16 14:08:00] DEBUG[22209] http.c: HTTP keeping session open. status_code:200
[May 16 14:08:00] DEBUG[22125][C-0000006e] res_rtp_asterisk.c: (0x7f4f80008180) RTP no remote address on instance, so dropping frame
[May 16 14:08:00] DEBUG[22209] http.c: HTTP Request URI is /ari/bridges/d0b8f93228cf41fbb596306fc913750e/addChannel
[May 16 14:08:00] DEBUG[22209] http.c: match request [ari/bridges/d0b8f93228cf41fbb596306fc913750e/addChannel] with handler [httpstatus] len 10
[May 16 14:08:00] DEBUG[22209] http.c: match request [ari/bridges/d0b8f93228cf41fbb596306fc913750e/addChannel] with handler [phoneprov] len 9
[May 16 14:08:00] DEBUG[22209] http.c: match request [ari/bridges/d0b8f93228cf41fbb596306fc913750e/addChannel] with handler [metrics] len 7
[May 16 14:08:00] DEBUG[22209] http.c: match request [ari/bridges/d0b8f93228cf41fbb596306fc913750e/addChannel] with handler [static] len 6
[May 16 14:08:00] DEBUG[22209] http.c: match request [ari/bridges/d0b8f93228cf41fbb596306fc913750e/addChannel] with handler [ari] len 3
[May 16 14:08:00] DEBUG[22209] http.c: Match made with [ari]
[May 16 14:08:00] DEBUG[22209] http.c: HTTP consuming request body
[May 16 14:08:00] DEBUG[22209] res_ari.c: Finding handler for bridges/d0b8f93228cf41fbb596306fc913750e/addChannel
[May 16 14:08:00] DEBUG[22209] res_ari.c: Finding handler for bridges
[May 16 14:08:00] DEBUG[22209] res_ari.c: Checking ari bridges: Explicit match with bridges
[May 16 14:08:00] DEBUG[22209] res_ari.c: Finding handler for d0b8f93228cf41fbb596306fc913750e
[May 16 14:08:00] DEBUG[22209] res_ari.c: Checking bridges bridgeId: Matched wildcard.
[May 16 14:08:00] DEBUG[22209] res_ari.c: No explicit handler found for d0b8f93228cf41fbb596306fc913750e. Using wildcard bridgeId.
[May 16 14:08:00] DEBUG[22209] res_ari.c: Finding handler for addChannel
[May 16 14:08:00] DEBUG[22209] res_ari.c: Checking bridgeId addChannel: Explicit match with addChannel
[May 16 14:08:00] DEBUG[22209] http.c: HTTP keeping session open. status_code:400
[May 16 14:08:00] DEBUG[22209] http.c: HTTP closing session. Top level
[May 16 14:08:00] DEBUG[22216] http.c: HTTP opening session. Top level
[May 16 14:08:00] DEBUG[22216] http.c: HTTP Request URI is /ari/bridges/d0b8f93228cf41fbb596306fc913750e/addChannel
[May 16 14:08:00] DEBUG[22216] http.c: match request [ari/bridges/d0b8f93228cf41fbb596306fc913750e/addChannel] with handler [httpstatus] len 10
[May 16 14:08:00] DEBUG[22216] http.c: match request [ari/bridges/d0b8f93228cf41fbb596306fc913750e/addChannel] with handler [phoneprov] len 9
[May 16 14:08:00] DEBUG[22216] http.c: match request [ari/bridges/d0b8f93228cf41fbb596306fc913750e/addChannel] with handler [metrics] len 7
[May 16 14:08:00] DEBUG[22216] http.c: match request [ari/bridges/d0b8f93228cf41fbb596306fc913750e/addChannel] with handler [static] len 6
[May 16 14:08:00] DEBUG[22216] http.c: match request [ari/bridges/d0b8f93228cf41fbb596306fc913750e/addChannel] with handler [ari] len 3
[May 16 14:08:00] DEBUG[22216] http.c: Match made with [ari]
[May 16 14:08:00] DEBUG[22216] http.c: HTTP consuming request body
[May 16 14:08:00] DEBUG[22216] res_ari.c: Finding handler for bridges/d0b8f93228cf41fbb596306fc913750e/addChannel
[May 16 14:08:00] DEBUG[22216] res_ari.c: Finding handler for bridges
[May 16 14:08:00] DEBUG[22216] res_ari.c: Checking ari bridges: Explicit match with bridges
[May 16 14:08:00] DEBUG[22216] res_ari.c: Finding handler for d0b8f93228cf41fbb596306fc913750e
[May 16 14:08:00] DEBUG[22216] res_ari.c: Checking bridges bridgeId: Matched wildcard.
[May 16 14:08:00] DEBUG[22216] res_ari.c: No explicit handler found for d0b8f93228cf41fbb596306fc913750e. Using wildcard bridgeId.
[May 16 14:08:00] DEBUG[22216] res_ari.c: Finding handler for addChannel
[May 16 14:08:00] DEBUG[22216] res_ari.c: Checking bridgeId addChannel: Explicit match with addChannel
[May 16 14:08:00] DEBUG[22216] http.c: HTTP keeping session open. status_code:400

They’re documented as being query parameters, not body parameters. Additionally the channel is the uniqueid of the channel in question.

The detailed steps are:

  • Create the bridge
  • Create the two channels representing the endpoints of the call
  • Wait for StasisStart events on each of your created channels; as you get each such event, you need to
  • Answer the channel, and
  • Attach it to the bridge.

And then listen for a ChannelDestroyed event indicating the end of the call.

I have some sample code in the track_call_ari_bridged_async script here.

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