Install/Mosquitto Mqtt Broker: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
See http://mosquitto.org | See http://mosquitto.org | ||
== Enable Mqtt == | |||
nano /etc/mosquitto/conf.d/mqtt.conf | |||
Add: | |||
listener 1883 | |||
protocol mqtt | |||
Restart the broker service: | |||
service mosquitto stop | |||
service mosquitto start | |||
tail /var/log/mosquitto/mosquitto.log # ensure no errors | |||
== Enable User Authentication == | |||
nano /etc/mosquitto/conf.d/auth.conf | |||
Add: | |||
allow_anonymous false | |||
password_file /etc/mosquitto/passwd | |||
Create an encrypted password (see different ways [http://unix.stackexchange.com/questions/52108/how-to-create-sha512-password-hashes-on-command-line here]) | |||
doveadm pw -s SHA512-CRYPT | |||
{SHA512-CRYPT}$6$4ETbaj7n..... | |||
Copy everything after the {SHA512-CRYPT} part. | |||
Create the password file: | |||
nano /etc/mosquitto/passwd | |||
Add your new user (fred), one user per line: | |||
fred:$6$4ETbaj7n..... | |||
Restart the broker service: | |||
service mosquitto stop | |||
service mosquitto start | |||
tail /var/log/mosquitto/mosquitto.log # ensure no errors | |||
== Enable Websocket == | == Enable Websocket == | ||
Revision as of 03:21, 24 May 2016
Enable Mqtt
nano /etc/mosquitto/conf.d/mqtt.conf
Add:
listener 1883 protocol mqtt
Restart the broker service:
service mosquitto stop service mosquitto start tail /var/log/mosquitto/mosquitto.log # ensure no errors
Enable User Authentication
nano /etc/mosquitto/conf.d/auth.conf
Add:
allow_anonymous false password_file /etc/mosquitto/passwd
Create an encrypted password (see different ways here)
doveadm pw -s SHA512-CRYPT
{SHA512-CRYPT}$6$4ETbaj7n.....
Copy everything after the {SHA512-CRYPT} part.
Create the password file:
nano /etc/mosquitto/passwd
Add your new user (fred), one user per line:
fred:$6$4ETbaj7n.....
Restart the broker service:
service mosquitto stop service mosquitto start tail /var/log/mosquitto/mosquitto.log # ensure no errors
Enable Websocket
See secure websocket
nano /etc/mosquitto/conf.d/ws.conf
For secure websocket (wss) add this:
listener 9001 protocol websockets certfile /etc/letsencrypt/live/playfulexploration.com/cert.pem cafile /etc/letsencrypt/live/playfulexploration.com/chain.pem keyfile /etc/letsencrypt/live/playfulexploration.com/privkey.pem
Alternatively for unsecure websocket (ws) omit the cert- and keyfiles:
listener 9001 protocol websockets
Restart the broker service:
service mosquitto stop service mosquitto start tail /var/log/mosquitto/mosquitto.log # ensure no errors
On the wappage's javascript use this to connect:
wss://playfulexploration.com:9001
or
ws://playfulexploration.com:9001