简体   繁体   English

星号AMI返回不正确的数据

[英]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. 从终端我得到预期的输出(在这种情况下,我希望在返回的信息中获得A:2

But when I connect to AMI via a PHP socket on the same server I get A:0 (the information has not populated correctly). 但是当我通过同一服务器上的PHP套接字连接到AMI时,我得到A:0 (信息没有正确填充)。

$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. 正在使用的AMI用户在manager.conf中具有正确的读取权限,并成功进行了身份验证。

[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? 我的问题是,为什么AMI会从控制台返回的内容中返回不同的信息?

As a side note, this issue also arises when using AMI to run: 附带说明,使用AMI运行时也会出现此问题:

asterisk*CLI>sip show peers

The console is returning the correct information while AMI is returning (Unspecified) for each IP address. 当AMI为每个IP地址返回(未指定)时 ,控制台将返回正确的信息。

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. 看来机器正在端口5038上保留较旧的Asterisk进程。杀死该进程并重新启动Asterisk后,AMI能够成功检索正确的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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