简体   繁体   中英

Asterisk AMI returning incorrect data

When running:

asterisk*CLI>queue show <queue-name>

from the terminal I get the expected output (in this case I am expecting to get A:2 within the returned information.

But when I connect to AMI via a PHP socket on the same server I get A:0 (the information has not populated correctly).

$data = '';
$socket = fsocketopen('127.0.0.1', '5038');

fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: username\r\n");
fputs($socket, "Secret: password\r\n\r\n");
fputs($socket, "Action: QueueStatus\r\n");
fputs($socket, "Action: Logoff\r\n\r\n");

while(!feof($socket)) {
    $data .= fread($socket, 8192);
}

fclose($socket);

$data = trim($data); // This string contains A:0 where I would expect A:2.

The AMI user being used has the correct read permissions in manager.conf and it authenticating successfully.

[username]
secret = password
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.0
read = system,call,log,verbose,command,agent,user,all
write = system,call,log,verbose,command,agent,user,all

My question is, why would AMI return different information from what the console is returning?

As a side note, this issue also arises when using AMI to run:

asterisk*CLI>sip show peers

The console is returning the correct information while AMI is returning (Unspecified) for each IP address.

So my system administrator took a look. It seems that the machine was holding onto an older Asterisk process on port 5038. After killing that process and starting Asterisk up again AMI was successfully able to retrieve the correct information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM