Install Mosquitto MQTT server on Epic PR1

This is at your own risk. I don’t support any accidents or screwups. I am sure Opto22 support won’t either, as this is using SSH.

Background Info - The Why
This is handy when you have multiple locations with no internet access but have setup network access (Wireless network, 900mhz packet radio, etc). This is not about a central MQTT server, but passing data from device to device without using PAC in the middle. My own setups are growing and there are a lot times we have to use our own IP networks with no central servers or Internet access. This lets me bypass building strategies where I have to worry about installing certificates between PR1’s.

Our ‘product’ line keeps growing and having to keep certificates and make sure that all works in a major pain. There is a Node-red plugin called Mosca, but even if you are not publishing a huge amount of data, it uses a lot of RAM and continues grow. In my testing it actually made my PR1 unstable and needed reboot as the memory load grew very high. Mosquitto is way more memory efficient.

This saves writing to a pac node controller which sucks when you start hitting with to many writes/reads. Opto needs to come up with a better queuing system for the controller as it can be overwhelmed quickly.
When building strategies with PAC Control, use tables as much as you can when using Node-Red, probably in general.

Have Fun!
Dan

Get Source & Make

wget https://mosquitto.org/files/source/mosquitto-1.5.8.tar.gz
tar -xzvf mosquitto-1.5.8.tar.gz
cd mosquitto-1.5.8
sudo make WITH_SRV=no

Add user

sudo useradd mosquitto

Install

sudo cp client/mosquitto_pub /usr/bin
sudo cp client/mosquitto_sub /usr/bin
sudo cp lib/libmosquitto.so.1 /usr/lib
sudo cp src/mosquitto /usr/bin
sudo cp src/mosquitto_passwd /usr/bin

sudo mkdir /etc/mosquitto/
sudo cp mosquitto.conf /etc/mosquitto/

Edit Mosquitto Config
sudo nano /etc/mosquitto/mosquitto.conf

Search for #allow_anonymous true and change the line to be:
allow_anonymous false
Search for #user root and change the line to be:
user mosquitto

Make sure you remove the pound sign from the start of both lines

Add user to mosquitto auth
sudo mosquitto_passwd -c /etc/mosquitto_pass.txt nodered

To Start on boot
(Uses VI. Need to know it’s commands)

crontab -e
@reboot  mosquitto -c /etc/mosquitto/mosquitto.conf &	

Add port to the firewall
https://YOURIP/manage/local/system/firewall
Port 1883

Reboot and publish to your local mqtt server

General Info:

To stop Mosquitto:
pgrep mosquitto
kill -9 PID (that you get from above command)

To Start Mosquitto without a reboot:
mosquitto -c /etc/mosquitto/mosquitto.conf &

#nodered is the user I am using, you can choose anything. Be careful, if you are asked twice, it’s because you have to enter your root password again. If it only asks once with confirmation, this is the password you are setting for mosquitto

I have sourced the authentication information from:

Please note, this does not include websockets support. Maybe in the future.

This is at your own risk. I don’t support any accidents or screwups. I am sure Opto22 support won’t either, as this is using SSH.

1 Like

before trying this, make sure that Python 3, and Python PIP have been installed.

without installing python 3… this procedure will fail on make at the SSH.h file header not found.

sudo apt-get install python3 should do it for you

1 Like

Small update on this thread…
With groov EPIC firmware 2.0 or better you can simply install Mosquitto through shell.

sudo apt-get update
sudo apt-get install mosquitto

Don’t forget to go into groov Manage and set the firewall if needed.

As @darbeau said, we don’t support it since it is using shell, but we are happy to make it a lot easier to install.

6 Likes

Hi @Beno @darbeau @scooter
Is still accurate?
I have an application where a customer wants to install an MQTT broker on an EPIC.
Thank you,
Rene

1 Like

@rgamero Yup.
Do the repo update and then install the broker (I just tested it on my EPIC now).

1 Like

@Beno Awesome! You opto people are alright. :+1: