Mosquitto-PHP icon indicating copy to clipboard operation
Mosquitto-PHP copied to clipboard

loop/loopFoever throw empty exception randomly

Open ChaojieZhang opened this issue 8 years ago • 2 comments

I am writing a client to save all chat to MySQL, but loop/loopForever not working correctly.
CODE: $c = new Mosquitto\Client('saveAllChat',1); $c->onConnect(function() use ($c) { $c->subscribe('#', 1); }); $c->onMessage(function($m) { // var_dump($m); }); $c->connect('127.0.0.1'); for ($i = 0; $i < 1000; $i++) { echo $i.' '; $c->loop(1); //the loop throw excption randomly, sometimes $i = 10, sometimes $i = 543 } ERROR: `PHP Fatal error: Uncaught exception 'Mosquitto\Exception' in /home/cj/www/dev/mqtt/onMeesage.php:18 Stack trace: #0 /home/cj/www/dev/mqtt/onMeesage.php(18): Mosquitto\Client->loop(1) #1 {main} thrown in /home/cj/www/dev/mqtt/onMeesage.php on line 18

Server environment: Ubuntu 14.04 LTS libmosquitto-dev installed from ppa:mosquitto-dev/mosquitto-ppa the extention was intalled by 'pecl install Mosquitto-alpha'

anyone have any idea?

ChaojieZhang avatar Dec 22 '16 09:12 ChaojieZhang

Absolutely the same here: after some seconds the loop:

for ($i = 0; $i < 10000; $i++) { // Loop around to permit the library to do its work $c->loop (100000); usleep (10); print $i . " "; } ends with the above exception ("Uncaught exception 'Mosquitto\Exception'"), no matter if calling loop without parameter, with 0, 1 or anything above. Same behaviour if using loopForever instead of making my own loop,

PHP Version 5.6.29. The Extension was installed with pecl install Mosquitto-Beta.

Anyone any ideas?

msedv avatar Jan 28 '17 00:01 msedv

can you try again with the latest released version? I've not yet managed to reproduce this.

mgdm avatar Mar 14 '17 19:03 mgdm