1

Using ARI (C#, AsterNET), I'm creating a channel via the Originate command:

   var channel = client.Channels.Originate($"SIP/{number}@{destination}", app: appName, callerId: CLI, timeout: timeout);

This works fine; however,timeout starts from when the channel is created, and in reality I'd like to timeout to only be enforced once the channel starts ringing.

Is there any way (via ARI) to manipulate the timeout setting once the channel is created - so I could, for example, create the channel with an arbitrary timeout, and then (re)set the timeout once the channel state has changed to RINGING?

KenD
  • 5,280
  • 7
  • 48
  • 85

2 Answers2

1

There is no way do timeout based on ringing in asterisk.

Not in dialplan, not in ARI or AMI or AGI. No at all.

Only complex things like listen for event and manualy hangup channels.

arheops
  • 15,544
  • 1
  • 21
  • 27
0

Instead of using originate:

POST /channels

you could use:

POST /channels/create

to create a channel without dialing immediately. This allows your Stasis Application to gain control of the channel before it is answered.

Before /channels/create, you should now be setting a StasisStart event handler that does /channels/dial and sets the timeout in this request.

This won't be for exactly when the channel starts ringing (since that is not possible to set), but it will be exactly when the channel is dialed, which is hopefully pretty close to what you're looking for.

Note: when using this method, you will likely want to be setting the Caller ID in the StasisStart event handler as well, since it cannot be set in the /channels/create request.

Matt
  • 902
  • 7
  • 20
  • For originate delay under very high load between originate placed and channel dialled - less then 0.2 seconds. So no point go this, not add anything. – arheops May 30 '19 at 23:50
  • 'setting the Caller ID in the StasisStart event handler'. Wrestling with this. Care for an example? – raarts Jul 20 '20 at 18:52