AMI command QueueStatus not available from time to time

Hello! I am new to Asterisk and right now maintain an application that creates a dashboard for our queues. To get information I need I use QueueStatus command (QueueStatus - Asterisk Documentation) and usually I get the information I need. But sometimes instead of this I get:

Error\r\nActionID: 3\r\nMessage: Invalid/unknown command: QueueStatus. Use Action: ListCommands to show available commands.

I suppose it happens during some problem or maintenance on Asterisk side, because when I look at logs I see that sometimes it cannot connect to Asterisk, and then it can connect but the command that should work doesn’t work as expected. Is it an expected behavior that in some cases AMI will return “Invalid/unknown command” when asked for queue status? Is there a way to check Asterisk “health” in order to understand that right now it is not working correctly?

Thanks in advance, I really appreciate your help.

That error could be caused by different causes. What I would check is this:

  • Is the appropriate module loaded.
  • Does the user used for the AMI connection, actually have the required privileges, you could try giving all privileges available as a troubleshooting step.

Hello! Thanks for your answer.

How can I check it?

It definitely does, because as I mentioned most of the time the user gets response as expected. I think if I had problem with privileges I wouldn’t be able to get QueueStatus at all.

I somehow missed the point that it works sometimes…

In that case it could be a matter of whatever software connects to Asterisk, sends something wrong… While it LOOKS right, nothing prevents it from being wrong on the binary level. Eg. sometimes adds a space at the beginning or end, uses wrong line separators etc.

It’s also possible, the command is executed at a point in time, where the module is not loaded, but shortly after it is.

Look at the packets sent, or check the Asterisk log for clues. If the software has debugging allowing you to log the communications, enable that, see what happens. If by “maintain” you mean bugfixes etc, and as such has access to the source, implement some logging to help troubleshooting.

It’s also possible that Asterisk isn’t fully loaded at the time of AMI connection.

Do you mean connection or do you mean the receipt of the action. I wouldn’t expect AMI to cache the list of valid actions on connection.

Receipt of the action.

That is my guess also. Is it possible to check loading status using AMI?

The problem is, that right now I have a health check route on my app, that among other things, checks that the app can connect to Asterisk (using “Action” login). But now I see, that if I can login it doesn’t mean that Asterisk is operating. For example, later in the app when it tries to get QueueStatus it fails and gets error. Of course I can include request for QueueStatus in health check and log problem, if I cannot get it, but maybe there is more correct way? I am new to Asterisk so it is not obvious to me how to do it right :slight_smile:

I am almost sure that everything is fine in this case, as the connection is done using python script (telnetlib library to be precise), thus it always sends the same requests. But I get your idea about Asterisk logs. Unfortunately, I am not the one who manages it but I will try to get them from colleagues.

The QueueStatus AMI Action does not return the queue name, It only returns the queue number.
How can I get the queue name, Is there other ami action that return the queue name

I’m not sure exactly how that telnet library works, however, telnet and a raw IP socket er NOT the same thing… There’s some control characters used in a telnet connection, that Asterisk would most likely NOT understand.

The only way to know exactly what Asterisk reacts to, is looking at what’s actually transmitted on the wire. If a control character is added before or after the action, Asterisk would most likely not understand it, and you would not see them when just dumping the printable characters to screen, instead of the actual bytes.

What do you mean by “Queue name”, the only thing that springs to my mind, is whatever you write in in queues.conf, like in this sample, you would mean “sales”. If you write a number in the square brackets, that’s all you’re gonna get.

[sales]
strategy=ringall
member => PJSIP/1109 ; Terry Jules - Director of Sales
member => PJSIP/1105 ; Garnet Claude - Sales Associate
member => PJSIP/1112 ; Franny Ocean - Sales Associate

To know whether Asterisk is fully booted a FullyBooted event is raised[1]. This is raised on all connections, even if Asterisk has been fully booted for some time.

The only “queue name” within Asterisk is the one @Chano mentioned. If that doesn’t match what you’re expecting, then the “queue name” you are referring to is something outside of Asterisk.

[1] FullyBooted - Asterisk Documentation

How is it possible to check this specific event after I establish connection? Can I check that Asterisk is fully booted using this event, if it was booted several hours before my connection was set or not?

Core show uptime ?

I can’t speak for your library or software. The event is emitted on every connection, regardless if it has been hours since Asterisk was started or not.

1 Like

I make some assumptions here…

I assume your software works as follows:

  1. It establishes a connection to Asterisk
  2. It enters an event processing loop, that listens for events from Asterisk, and handles them appropriately. (Eg. does something for interesting events, ignores everything else.)
  3. The processing loop works as follows:
    a. Listens for data on the network, with a timeout.
    b. When data is received, it checks if it got a partial, full or multiple events, if a partial event were received, it listens for more network data, if a full event were received it processes it, if multiple events were received, it separates them and processes them individually.
  4. There’s a feature somewhere, that allows to send commands TO Asterisk if needed.

In step number 2 you would listen for the “FullyBooted” event, which will allow everything else to proceed, until you receive this event, you only handle whatever events are incoming, but do not transmit any requests. Once “FullyBooted” is received, your software starts allowing transmission of requests as well.

How you implement it in your software is very depending on the structure of your code, but if you are using a class for handling communications with Asterisk, a class property/variable could be an option.

1 Like

Thank you for your answer, I did try to add the queue name [sales] to queues.conf and it did return as it should, but when I add a new queue from FreePBX, it asks for a queue number and a queue name with the rest of the additional data, so it will be added in queues_additional.conf by the inserted number for example [700], when I send the AMI Action QueueStatus, It returns the queue number “700” with other data but not the queue name

That’s a FreePBX issue. Obviously they call queue name, number, and have a queue name that Asterisk doesn’t know about. This forum is not suitable for questions about the workings of FreePBX.

I assume FreePBX has an API to retrieve that name, but it’s not an Asterisk thing. Try the FreePBX forums for that part.