ExtensionStateAction & ExtensionStateResponse

Dec 5, 2014 at 7:39 PM
I have an application where I want to check the extension status for the two extensions that I wish to connect in a call. My code is as follows:
var statusAction = new ExtensionStateAction
{
       Context = "from-internal",
       Exten = "5111"
};

var actionResponse = _manager.SendAction(statusAction, 5000);
var response = actionResponse as ExtensionStateResponse;
if (response != null)
{
       ExtensionStatus status;
       var stateResponse = response;
       Enum.TryParse(stateResponse.Status.ToString(), out status);
       return status.ToString();
}
I have an enum named ExtensionStatus defined as:
    public enum ExtensionStatus
    {
        NotFound = -1,
        Idle = 0,
        InUse = 1,
        Busy = 2,
        Unavailable = 4,
        Ringing = 8,
        OnHold = 16
    }
This usually works well, but occasionally, instead of receiving the expected ExtensionStateResponse, I get a ManagerResponse instead. Any idea why this would happen and what I can do to make sure an ExtensionStateResponse is returned?
Dec 8, 2014 at 3:43 PM
Can you provide a trace please of the AMI events?

See https://asternet.codeplex.com/discussions/572963 for more information on how to trace AsterNET.
Dec 9, 2014 at 5:03 PM
I added those bits to my app's config file, but the trace file never got created.

I discovered another issue in my app regarding creating too many manager connections to Asterisk and that caused problems. I've changed it to use a static connection that gets created when the app launches and so far, that seems to have resolved some issues. It's still in testing at the moment so not sure if that resolved the ExtensionStatus problem as well. I'll let you know. Thanks!
Dec 9, 2014 at 9:03 PM
Yeah, you should really only use one connection for your app.

Hope you're testing goes well.