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?
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.
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
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.
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.
member => PJSIP/1109 ; Terry Jules - Director of Sales
member => PJSIP/1105 ; Garnet Claude - Sales Associate
member => PJSIP/1112 ; Franny Ocean - Sales Associate
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?
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.)
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.
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.
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 , when I send the AMI Action QueueStatus, It returns the queue number “700” with other data but not the queue name