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
//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
//Step 5 - Dial the party
//Statis start event for the dialed party
//Step 1 - Answering the party using second 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.