Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PAMI Disconnect‏ and read Code #77

Closed
qasimkhans opened this issue Jun 19, 2015 · 6 comments
Closed

PAMI Disconnect‏ and read Code #77

qasimkhans opened this issue Jun 19, 2015 · 6 comments

Comments

@qasimkhans
Copy link

I am using PAMI to get Asterisk Manager Events. please see my code below. I wanted to get $event->getDialStatus() == 'ANSWER' of Dial Event and as condition true, i want Asterisk Manager to be disconnected and read the remaining code. in other words i just want to get some events store in DB and move to remaining after that. currently i am getting following error. Thanks.

'127.0.0.1', 'scheme' => 'tcp://', 'port' => 5038, 'username' => 'ncs', 'secret' => 'ncs', '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"; ?>

PHP 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 /scripts/pami.php(95): PAMI\Client\Impl\ClientImpl->process()
#2 {main}

thrown in /usr/share/pear/PAMI/Client/Impl/ClientImpl.php on line 236

@marcelog
Copy link
Owner

It seems asterisk is closing the connection, you should be able to find out more information in the asterisk logs

@qasimkhans
Copy link
Author

That is right, i want asterisk manager connection to be closed. but i am getting above error,

@marcelog
Copy link
Owner

You are closing the connection but the loop keeps calling the process() method, you should get out of that loop if you want to end the program.

@qasimkhans
Copy link
Author

can you please let me know how to get out of that loop after close the connection. Thanks

@marcelog
Copy link
Owner

this is not a pami issue, closing this one then.

@engbanna
Copy link

engbanna commented Aug 6, 2017

@marcelog So where can I find the solution for this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants