-
Notifications
You must be signed in to change notification settings - Fork 6
Notification Service Configuration
-
Download mosquitto
wget http://mosquitto.org/files/source/mosquitto-1.4.3.tar.gz
-
Install some packages
sudo apt-get install libwrap0-dev
sudo apt-get install libssl-dev
sudo apt-get install uuid-dev
-
Uncompress targz
tar zxf mosquitto-1.4.3.tar.gz
-
Compile and install
make
make install
ldconfig
make clean
iptables -A INPUT -p tcp -m tcp --dport 1883 -j ACCEPT
*If there is some error while compiling, go to this webpage:
https://goochgooch.wordpress.com/2014/08/01/building-mosquitto-1-4/
-
Starting mosquitto
Open a terminal and type:
mosquitto -p portnumber
-
Checking mosquitto is running
Open a terminal and type:
ps -ef | grep mosq && netstat -tln | grep portnumber
*You will need to install mqtt through npm install mqtt -g
example.js:
var mqtt = require('mqtt');
var client = mqtt.connect('mqtt://localhost:6969');
client.on('connect', function () {
client.subscribe('presence');
console.log("Connected");
client.publish('presence', 'Hello mqtt');
});
client.on('error',function(error) {
console.log(error);
});
client.on('message', function (topic, message) {
// message is Buffer
console.log(message.toString());
client.end();
});
Run:
node example.js.
You must see in the consolelog “Hello mqtt”
Full information about configuration file :
https://eclipse.org/mosquitto/man/mosquitto-conf-5.php
You can load a configuration file with -c option. By default mosquitto load mosquito.conf file.
mosquito -c configurationfile
Configuration lines start with a variable name. The variable value is separated from the name by a single space.
There are a few possibilities of authentication
-
The simplest option is to have no authentication at all.This is the default if no other options are given.
-
You can use a password file option to define the valid usernames and poasswords. You must be sure to use network encryption if you are using this options otherwise they will be vulnerable to interception.
-
Certificate based encryption.
*You can use all of them at once.
Mosquitto: http://mosquitto.org/documentation/
# warning
: now our docs are being published in our gitbook and available on our website. Visit http://docs.netbeast.co/
- Visit our site https://netbeast.co
- Mail us: staff [at] netbeast.co
- Report a bug or enter discussion at issues
- Other resources: Dashboard, Netbeast API