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

Connection error in PAMI

shikhavyas06 opened this issue · comments

I am using PAMI for asterisk manager.I am totally new to this.Here is my code

error_reporting(E_ALL);
ini_set('display_errors', 1);

use PAMI\Client\Impl\ClientImpl as PamiClient;
require_once 'PAMI/Autoloader/Autoloader.php';
PAMI\Autoloader\Autoloader::register();

$pamiClientOptions = array(
'host' => '127.0.0.1',
'scheme' => 'tcp://',
'port' => 5038,
'username' => 'tarunM',
'secret' => 'f713cea2065d94f9b942c97c1b8caacf',
'connect_timeout' => 10000,
'read_timeout' => 10000
);

$pamiClient = new PamiClient($pamiClientOptions);

// Open the connection
$pamiClient->open();

use PAMI\Message\Event\EventMessage;
use PAMI\Message\Event\DialEvent;

$pamiClient->registerEventListener(function (EventMessage $event) {
print_r($event);
},
function ($event) {
$re = $event instanceof DialEvent && $event->getDialStatus() == 'ANSWER';
if ($re){
echo "Found Event\n";
global $pamiClient;
$pamiClient->close();
}
}
);

$running = true;

while($running) {
$pamiClient->process();
usleep(1000);
}

echo "Code Ended>>>>>>>>>>>>>>>>>>> Read This Line\n";

it is showing this error
DEBUG - ------ Sending: ------ action: Login actionid: 1457504735.3649 username: tarunM secret: f713cea2065d94f9b942c97c1b8caacf ---------- Fatal error: Uncaught exception 'PAMI\Client\Exception\ClientException' with message 'Error reading' in /usr/share/pear/PAMI/Client/Impl/ClientImpl.php:236 Stack trace: #0 /usr/share/pear/PAMI/Client/Impl/ClientImpl.php(258): PAMI\Client\Impl\ClientImpl->getMessages() #1 /usr/share/pear/PAMI/Client/Impl/ClientImpl.php(410): PAMI\Client\Impl\ClientImpl->process() #2 /usr/share/pear/PAMI/Client/Impl/ClientImpl.php(181): PAMI\Client\Impl\ClientImpl->send(Object(PAMI\Message\Action\LoginAction)) #3 /var/www/html/AMI/PAMI-master/index.php(22): PAMI\Client\Impl\ClientImpl->open() #4 {main} thrown in /usr/share/pear/PAMI/Client/Impl/ClientImpl.php on line 236

Your Asterisk is closing the connection, you should check the asterisk console and manager.conf options for more information.

please can you help me with this error
PHP Fatal error: Uncaught exception 'PAMI\Client\Exception\ClientException' with message 'Error reading' in /vendor/marcelog/pami/src/PAMI/Client/Impl/ClientImpl.php:238
Stack trace:
#0 /var/www/html/ems/vendor/marcelog/pami/src/PAMI/Client/Impl/ClientImpl.php(261): PAMI\Client\Impl\ClientImpl->getMessages()
#1 /var/www/html/ems/vendor/marcelog/pami/src/PAMI/Client/Impl/ClientImpl.php(409): PAMI\Client\Impl\ClientImpl->process()
#2 /var/www/html/ems/vendor/marcelog/pami/src/PAMI/Client/Impl/ClientImpl.php(183): PAMI\Client\Impl\ClientImpl->send(Object(PAMI\Message\Action\LoginAction))
#3 /var/www/html/ems/CallListener2.php(262): PAMI\Client\Impl\ClientImpl->open()
#4 /var/www/html/ems/CallListener2.php(299): CallListener2->run()
#5 {main}
thrown in /var/www/html/ems/vendor/marcelog/pami/src/PAMI/Client/Impl/ClientImpl.php on line 238