Hi!
Yes, I use this mqtt broker for a while now ( some Tasmota devices and my own weather station ).
I have disabled anonymous connexion and use only one user ‘mqtt’ + password (no SSL, it’s only on my LAN).
I rebooted the emoncms device after changing settings (I was not sure how to restart/load new settings).
Ok I found several issues
mosquitto-client was not installed…now it’s installed.
I subscribed with the command line to ‘#’ so I can see all topics.
It works fine.
I was able to see the connexion from 192.168.1.152 in mosquitto (due to mosquitto_sub).
I reboot again, but no connexion from emoncms.
I though it was maybe missing some dependancies in emoncms and I found this page:
An other hit!
My emoncms is installed in /var/www/html
I corrected the link but there seems to be some path hardcoded to /var/www/emoncms… Inside the mqtt files.
I will check a bit more, maybe re install will be necessary.
Btw, I run 9.9.9, I expect not too old (download recently)
Hi !
The point is that I installed emoncms in /var/www/html
I followed the howto, but I come to this directory, I figured out that /var/www was not the right place for my setup, this directory is not visible using http from my laptop.
Would it work with a link the other way ? I mean: ln -s /var/www/html/emoncms /var/www/emoncms ?
Maybe, I can’t remember; apache is a bit strict about following symlinks so depending on how yours is configured and exactly what paths are followed you may or may not trip up over something. I can’t be bothered to work it out - it’s simpler just to try it
But even easier would probably be to just move your install
mv /var/www/html/emoncms /var/www
and then install the same link that Paul showed you. That way you end up with a common situation that will be easier next time you have a problem (if you do!)
May 23 12:03:16 gunther systemd[1]: emoncms_mqtt.service: Service hold-off time over, scheduling restart.
May 23 12:03:16 gunther systemd[1]: emoncms_mqtt.service: Scheduled restart job, restart counter is at 856.
May 23 12:03:16 gunther systemd[1]: Stopped Emoncms emoncms_mqtt script.
May 23 12:03:16 gunther systemd[1]: Started Emoncms emoncms_mqtt script.
May 23 12:03:16 gunther emoncms_mqtt[31043]: PHP Fatal error: Uncaught Error: Class 'Mosquitto\Client' not found in /var/www/emoncms/scripts/services/emoncms_mqtt/emoncms_mqtt.php:113
May 23 12:03:16 gunther emoncms_mqtt[31043]: Stack trace:
May 23 12:03:16 gunther emoncms_mqtt[31043]: #0 {main}
May 23 12:03:16 gunther emoncms_mqtt[31043]: thrown in /var/www/emoncms/scripts/services/emoncms_mqtt/emoncms_mqtt.php on line 113
May 23 12:03:16 gunther emoncms_mqtt[31043]: Fatal error: Uncaught Error: Class 'Mosquitto\Client' not found in /var/www/emoncms/scripts/services/emoncms_mqtt/emoncms_mqtt.php:113
May 23 12:03:16 gunther emoncms_mqtt[31043]: Stack trace:
May 23 12:03:16 gunther emoncms_mqtt[31043]: #0 {main}
May 23 12:03:16 gunther emoncms_mqtt[31043]: thrown in /var/www/emoncms/scripts/services/emoncms_mqtt/emoncms_mqtt.php on line 113
May 23 12:03:16 gunther systemd[1]: emoncms_mqtt.service: Main process exited, code=exited, status=255/n/a
May 23 12:03:16 gunther systemd[1]: emoncms_mqtt.service: Failed with result 'exit-code'.
line 113 of the php file is: $mqtt_client = new Mosquitto\Client($mqtt_server['client_id'],true);
Yes I assume it’s to create the mqtt client.
but does not work. Maybe the php mosquitto addon is not correctly installed, but I followed the howto.
Only changed 7.0 to 7.2 here:
/etc/php/7.0/mods-available/mosquitto.ini
(I dont have 7.0 directory)
I try to find a short php test of mosquitto module
edit:
hmm I guess it’s an issue with php mosquitto module
and got this error in apache log: [Thu May 23 12:34:14.899863 2019] [php7:error] [pid 19351] [client 192.168.1.14:44826] PHP Fatal error: Uncaught Error: Class 'Mosquitto\\Client' not found in /var/www/html/test2.php:3\nStack trace:\n#0 {main}\n thrown in /var/www/html/test2.php on line 3
edit2: short code to test the module:
<?php
if (!extension_loaded('Mosquitto-php')) {
echo "Mosquitto not loaded";
} else {
echo "Mosquitto loaded";
}
?>
shows Mosquitto not loaded on my side.
I will dig on this
I think just running the revised install line will overerite the alpha version, but watch for error messages and check the version afterwards, worse case, you will need to remove and reinstall the extension (a couple more lines that’s all).
One step forward
I uninstalled alpha and installed beta.
I passed the line 113 !! but now stop on line 155 $publish_to_mqtt = $redis->hgetall("publish_to_mqtt");
syslog:
May 23 15:26:39 gunther emoncms_mqtt[1550]: PHP Fatal error: Uncaught Error: Call to a member function hgetall() on boolean in /var/www/emoncms/scripts/services/emoncms_mqtt/emoncms_mqtt.php:155
May 23 15:26:39 gunther emoncms_mqtt[1550]: Stack trace:
May 23 15:26:39 gunther emoncms_mqtt[1550]: #0 {main}
May 23 15:26:39 gunther emoncms_mqtt[1550]: thrown in /var/www/emoncms/scripts/services/emoncms_mqtt/emoncms_mqtt.php on line 155
May 23 15:26:39 gunther emoncms_mqtt[1550]: Fatal error: Uncaught Error: Call to a member function hgetall() on boolean in /var/www/emoncms/scripts/services/emoncms_mqtt/emoncms_mqtt.php:155
May 23 15:26:39 gunther emoncms_mqtt[1550]: Stack trace:
May 23 15:26:39 gunther emoncms_mqtt[1550]: #0 {main}
May 23 15:26:39 gunther emoncms_mqtt[1550]: thrown in /var/www/emoncms/scripts/services/emoncms_mqtt/emoncms_mqtt.php on line 155
May 23 15:26:39 gunther systemd[1]: emoncms_mqtt.service: Main process exited, code=exited, status=255/n/a
May 23 15:26:39 gunther systemd[1]: emoncms_mqtt.service: Failed with result ‘exit-code’.
good point: logs from my mosquitto broker shows connexions from emoncms
(with socket error a few seconds later)
@borpin Yes, I have seen this discussion too but not sure what to do? shall I downgrade to 7.0 (not sure how to do but I can search) ?
Alpha or any beta less than 0.4.0 certainly won’t support any php 7.?, but 0.4.0 is only listed as php 7.0 and there are reports of it working fine with 7.1 so whilst I’ve not seen any thing about using 7.2, certainly 0.4.0 is the better option to try.
@notme - What versions of redis server and redis php extension are you using? I assume they are both installed and also enabled in settings.conf.