# Installing Mosquitto for emoncms

**URL:** <https://community.openenergymonitor.org/t/installing-mosquitto-for-emoncms/6263>\
**Category:** Installation\
**Tags:** mosquitto, pecl\
**Created:** [15 January 2018 18:44 UTC](https://community.openenergymonitor.org/t/installing-mosquitto-for-emoncms/6263 "2018-01-15T18:44:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nick](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/nick/32/170_2.png) [@nick](https://community.openenergymonitor.org/u/nick)\
**Post date:** [15 January 2018 18:44 UTC](https://community.openenergymonitor.org/t/installing-mosquitto-for-emoncms/6263/1 "2018-01-15T18:44:45Z")

</div>

> [@Mqtt\_input script run as systemd instead of initd](https://community.openenergymonitor.org/t/mqtt-input-script-run-as-systemd-instead-of-initd/2689/27):
>
> sudo systemctl enable mqtt\_input.service

I’m trying to get this to run on my Ubuntu installed emoncms (/var/www/html/emoncms). Have edited the locations to suit, but can’t get mqtt\_input to run.

Jan 15 14:47:46 ip-172-31-45-141 systemd[1]: Stopped LSB: Starts phpmqtt\_input agent daemon at boot time.  
Jan 15 14:47:46 ip-172-31-45-141 systemd[1]: mqtt\_input.service: Unit entered failed state.  
Jan 15 14:47:46 ip-172-31-45-141 systemd[1]: mqtt\_input.service: Failed with result ‘exit-code’.

I have tried running the underlying php file directly …

ubuntu@ip-172-31-45-141:/var/www/html/emoncms/scripts$ sudo php phpmqtt\_input.php  
PHP Fatal error: Uncaught Error: Class ‘Mosquitto\Client’ not found in /var/www/html/emoncms/scripts/phpmqtt\_input.php:101  
Stack trace:  
#0 {main}  
thrown in /var/www/html/emoncms/scripts/phpmqtt\_input.php on line 101

Any ideas?

Thanks

---

<div class="post-metadata">

**Author:** ![nick](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/nick/32/170_2.png) [@nick](https://community.openenergymonitor.org/u/nick)\
**Post date:** [15 January 2018 18:48 UTC](https://community.openenergymonitor.org/t/installing-mosquitto-for-emoncms/6263/2 "2018-01-15T18:48:07Z")

</div>

Here’s my incoming MQTT messages …

emon/44/1 4960  
emon/44/2 3352  
emon/44/3 2170  
emon/52/1 9  
emon/52/2 3003  
emon/46/1 6270  
emon/46/2 2940  
emon/46/3 2250  
emon/43/1 9990  
emon/43/2 3362  
emon/43/3 710  
emon/52/1 9  
emon/52/2 3003  
emon/46/1 6270

And here’s my settings …

```
$mqtt_enabled = true; // Activate MQTT by changing to true
$mqtt_server = array( 'host' => 'localhost',
                      'port' => 1883,
                      'user' => 'xxxxx',
                      'password' => 'xxxxx',
                      'basetopic'=> 'emon'
                      );
```

---

<div class="post-metadata">

**Author:** ![borpin](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/borpin/32/193_2.png) [@borpin](https://community.openenergymonitor.org/u/borpin)\
**Post date:** [15 January 2018 19:49 UTC](https://community.openenergymonitor.org/t/installing-mosquitto-for-emoncms/6263/3 "2018-01-15T19:49:37Z")

</div>

Obvious questions

- Have you followed these [instructions](https://github.com/emoncms/emoncms/blob/master/docs/RaspberryPi/MQTT.md)?
- You can subscribe to the MQTT feed from the command line using the same details as in the settings?

---

<div class="post-metadata">

**Author:** ![nick](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/nick/32/170_2.png) [@nick](https://community.openenergymonitor.org/u/nick)\
**Post date:** [15 January 2018 20:09 UTC](https://community.openenergymonitor.org/t/installing-mosquitto-for-emoncms/6263/4 "2018-01-15T20:09:34Z")

</div>

Aha, thanks. Had just got to installing sudo pecl install Mosquitto-alpha

That seems to have fixed my issue. And now am running just on mqtt.

Thanks for pointing me there …

Nick

---

<div class="post-metadata">

**Author:** ![pb66](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/pb66/32/27_2.png) [@pb66](https://community.openenergymonitor.org/u/pb66)\
**Post date:** [15 January 2018 20:44 UTC](https://community.openenergymonitor.org/t/installing-mosquitto-for-emoncms/6263/5 "2018-01-15T20:44:52Z")

</div>

A post was merged into an existing topic: [Raspbian Stretch](https://community.openenergymonitor.org/t/raspbian-stretch/5096)

---

<div class="post-metadata">

**Author:** ![pb66](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/pb66/32/27_2.png) [@pb66](https://community.openenergymonitor.org/u/pb66)\
**Post date:** [15 January 2018 20:47 UTC](https://community.openenergymonitor.org/t/installing-mosquitto-for-emoncms/6263/6 "2018-01-15T20:47:21Z")

</div>

I wonder why we are still using mosquitto-alpha? Anyone know?

> [@Raspbian Stretch](https://community.openenergymonitor.org/t/raspbian-stretch/5096/55):
>
> The last alpha version was 0.2.2 released 20 Mar 2014, Since then the mosquitto extension for PHP has passed to beta (v0.3.0 Sept 2015) and updated again to 0.4.0 13 March 2017.
> 
> I noted the linked emoncms guide for installing mosquitto has been revised for PHP7 to include the required symlinking, however, looking at the extension changelog, PHP 7.0 wasn’t officially supported until the last beta version (0.4.0 Mar 17) so I’m guessing “Stretch” users at the very least should be on the beta version?

---

<div class="post-metadata">

**Author:** ![glyn.hudson](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/glyn.hudson/32/35003_2.png) [@glyn.hudson](https://community.openenergymonitor.org/u/glyn.hudson)\
**Post date:** [16 January 2018 12:07 UTC](https://community.openenergymonitor.org/t/installing-mosquitto-for-emoncms/6263/7 "2018-01-16T12:07:33Z")

</div>

A post was split to a new topic: [Upgrading emonSD Mosquito version?](https://community.openenergymonitor.org/t/upgrading-emonsd-mosquito-version/6265)
