Daniel - Asterisk
2011-Aug-01 20:24 UTC
[asterisk-users] Problems with AMI connections (Asterisk 1.8.3.2)
Hi guys, I hope you could help me. I am trying to get connected through AMI but something is not working. Both php code and manager.conf were working well in asterisk 1.4 1. Sometimes it gets connected and sometimes it doesn't: == Connect attempt from '192.168.25.241' unable to authenticate == Connect attempt from '192.168.25.241' unable to authenticate == Manager 'mark' logged on from 192.168.25.241 2. When connected there's a message that appears just before the connection crashes: == Manager 'mark' logged on from 192.168.25.241 [Jul 26 16:29:14] ERROR[1579]: utils.c:1178 ast_careful_fwrite: fwrite() returned error: Broken pipe [Jul 26 16:29:14] ERROR[1579]: utils.c:1178 ast_careful_fwrite: fwrite() returned error: Broken pipe == Manager 'mark' logged off from 192.168.25.241 *This is my manager.conf:* [general] enabled = yes port = 5038 bindaddr = 0.0.0.0 webenabled = no [mark] secret = mysecret permit=0.0.0.0/255.255.255.0 read = system,call,log,verbose,command,agent,user,originate write = system,call,log,verbose,command,agent,user,originate *This is my code in PHP*: <?php function ast_claves(){ $socket fsockopen('192.168.25.18','5038',$errno,$errstr,10); fwrite($socket,"Action: Login\r\n"); fwrite($socket,"UserName: mark\r\n"); fwrite($socket,"Secret: mysecret\r\n\r\n"); fwrite($socket,"Action: DBPut\r\n"); fwrite($socket,"Family: authenticate/jorge\r\n"); fwrite($socket,"Key: 123456\r\n"); fwrite($socket,"Value: pbx-a\r\n"); fwrite($socket,"Action: Logoff\r\n\r\n"); fclose($socket); } ast_claves(); ?> *These are the software I am running:* Sistema operativo ? Debian 6.0 squeeze 2.6.32-5-686 Version de asterisk ? Asterisk 1.8.3.2 Version de Php ? php 5.3.3-7+squeeze1 Thanks ins advance. Elder -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20110801/e0f7a621/attachment.htm>
Paul Belanger
2011-Aug-01 20:35 UTC
[asterisk-users] Problems with AMI connections (Asterisk 1.8.3.2)
On 11-08-01 04:24 PM, Daniel - Asterisk wrote:> <?php > function ast_claves(){ > > $socket > fsockopen('192.168.25.18','5038',$errno,$errstr,10); > > > fwrite($socket,"Action: Login\r\n"); > > fwrite($socket,"UserName: mark\r\n"); > > fwrite($socket,"Secret: mysecret\r\n\r\n"); > > fwrite($socket,"Action: DBPut\r\n"); > > fwrite($socket,"Family: authenticate/jorge\r\n"); > > fwrite($socket,"Key: 123456\r\n"); > > fwrite($socket,"Value: pbx-a\r\n"); > > fwrite($socket,"Action: Logoff\r\n\r\n"); > > > fclose($socket); > > } > > ast_claves(); > > ?> >You are closing the socket before reading the result of 'Logoff' and Asterisk is complaining. -- Paul Belanger Digium, Inc. | Software Developer twitter: pabelanger | IRC: pabelanger (Freenode) Check us out at: http://digium.com & http://asterisk.org