sensorhub-mqtt-server
v0.2.2
Published
A MQTT-broker with wildcard support built for VAC Thuistechnologie
Downloads
6
Readme
Sensorhub server
This is the sensorhub server. In short, it's a MQTT broker. In full, it's a message router with authentication, retain and wildcard support.
The server is part of the sensorhub project at VAC Thuistechnologie. The goal of this project is to provide an easy to use, platform independent system for connecting sensors and applications using the lightweight MQTT protocol. Other applications include a websocket bridge, a Philips Hue bridge, a Kadex bridge, a Plugwise bridge and many more. Adding your own is easy and we encourage you to do so.
Usage
The server is meant to be used as a standalone application. It's therefore not recommended to run it as a node module.
To start the server, simply install the application (using git clone or download as a zip) and running:
npm start
After the server is started, clients can subscribe and publish messaged like they normally would on a MQTT system. A client on this server can, however, use wildcard to subcribe to messages like so:
// Subscribe to all topics ending with temperature using a wildcard
mqttclientlibrary.subscribe("*/temperature");
The client will now be notified of all topics ending with /temperature
, like /vac/office/temperature
for example. The content of this message, the payload, is defined by the user; it can be a string, a number or any else, like binary buffer.
Configuration
On start up, the server will look for two configuration files in the application's root directory. The first is the (obligatory) config_defaults.json
file. Seconf is the user's config.json
file.
The config_defaults.json
file contains all the default parameters the server needs to start up. Using only the default configuration, the server is fully functional. The defaults file looks like this:
{
"ip" : "0.0.0.0",
"port": 1883,
"users": {
"username":"password"
}
}
After loading the default configuration, the server will try and read the config.json
file, also located in the root folder. The keys in this file will override the ones from de default configuration.
Note: the config.json
file is ignored by git, so creating or changing the config.json
file won't show up as a change in the git repository. This is by intention of course, so you can freely change your config file.
Authentication
At this point, the server authenticates users via the config.json
file, where users and passwords are stored using a user-password key-value object. At some point later in time, more advanced authentication methods will be made available.