Express based web application to show sensor data coming from remote MQTT broker.
First of all install the required packages:
$ npm install
- Rename server.js.sample to server.js:
$ mv server.js.sample server.js
- Edit the server.js file according to your deployment:
// In case of MQTTS (TLS):
var connectOptions = {
host: "<MQTT_server_IP_or_hostname>",
port: 8883,
protocol: "mqtts",
keepalive: 10,
clientId: "test_client_01",
protocolId: "MQTT",
protocolVersion: 4,
clean: true,
reconnectPeriod: 2000,
connectTimeout: 2000,
cert: fs.readFileSync("ca.crt"),
rejectUnauthorized: false,
};
// In case of MQTT:
var connectOptions = {
host: "<MQTT_server_IP_or_hostname>",
port: 1883,
protocol: "mqtt",
keepalive: 10,
clientId: "test_client_01",
protocolId: "MQTT",
protocolVersion: 4,
clean: true,
reconnectPeriod: 2000,
connectTimeout: 2000
};
var topic="<topic_to_subscribe>";
Run the backend:
$ npm start
Then, open a web browser and type the following URL: http://localhost:4200 In case that the client is connected from a remote host, modify the public/index.html file in order to set your backend IP settings.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D