Unable to answer incoming call using ARI

Hello everyone,

We are facing an issue to answer an incoming call using ARI (Asterisk Version 16.x). The error appears: “Channel is in invalid state”.

We have implemented the code in a way that on ‘Statis Start Event’, we create a bridge, add the dialer party channel, created a channel for dialed party and add them into a bridge. Once the other party rings, we get another ‘statis start event’ and this time, it is for channel id for the dialed party. At this stage, if we answer the call, the error appears “Channel is in invalid state. Response status code does not indicate success: 412 (Precondition Failed).”

Below is code snippet (C#)

//Statis start event for the dialer party

//Step 1 - Create bridge with app = hello-world i.e. statis application
SimpleBridge = ARIClient.Bridges.Create(“mixing”, Guid.NewGuid().ToString(), “hello-world”);

//Step 2 - Add dialer party channel to bridge
ARIClient.Bridges.AddChannel(SimpleBridge.Id, event.Channel.Id);

//Step 3 - Create a channel for the number to be dialed i.e. 7002
Channel objchannel = ARIClient.Channels.Create(“SIP/7002”, “hello-world”);

//Step 4 - Add the dialing party channel to bridge
ARIClient.Bridges.AddChannel(SimpleBridge.Id, objchannel.Id);

//Step 5 - Dial the party
ARIClient.Channels.Dial(objchannel.Id, event.Channel.Caller.Number);

//Statis start event for the dialed party

//Step 1 - Answering the party using second channel id
ActionClient.Channels.Answer(event.Channel.Id);

The above line throws as error: “Channel is in invalid state. Response status code does not indicate success: 412 (Precondition Failed).”

We are struggling to get it working and has a customer site waiting for the solution. Any prompt help would be highly appreciated.

Thank you.

You can’t answer a dialed channel, which if your logic is correct - you are. You aren’t answering the calling party.

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