marcelog / PAMI

PHP Asterisk Manager Interface ( AMI ) supports synchronous command ( action )/ responses and asynchronous events using the pattern observer-listener. Supports commands with responses with multiple events. Very suitable for development of operator consoles and / or asterisk / channels / peers monitoring through SOA, etc

Home Page:http://marcelog.github.com/PAMI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error connecting to ami: php_network_getaddresses: getaddrinfo failed: Name or service not known

douglasroos opened this issue · comments

I'm trying to connect to AMI from a remote server, via telnet the connection works fine but with the PAMI it always gives the same error: Error connecting to ami: php_network_getaddresses: getaddrinfo failed: Name or service not known.

$pamiClientOptions = array(
            'host' => env('ASTERISK_HOST'),
            'scheme' => 'tcp://',
            'port' => env('ASTERISK_AMI_PORT'),
            'username' => env('ASTERISK_AMI_USER'),
            'secret' => env('ASTERISK_AMI_SECRET'),
            'connect_timeout' => 10000,
            'read_timeout' => 10000,
        );

        $pamiClient = new PamiClient($pamiClientOptions);

        $pamiClient->open();

        $originateMsg = new OriginateAction();
        $originateMsg->setContext('automated-call');
        $originateMsg->setPriority('1');
        $originateMsg->setExtension('s');
        $originateMsg->setCallerId('4122479501');
        $originateMsg->setTimeout(60000);
        $originateMsg->setAsync(true);
        $originateMsg->setActionID(1);
        $originateMsg->setVar('file=archivo.wav');
        $originateMsg->setVar('agi_callerid=4123089501');
        $pamiClient->send($originateMsg);

Already tried placing the host and credentials manually but same response. The server is Asterisk vanilla 16. As I say connection via telnet from the same server where the code is located works.