Skip to content

Express based web application to show sensor data coming from remote MQTT broker.

License

Notifications You must be signed in to change notification settings

etxahun/nodejs_mqtt_socketio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nodejs_mqtt_socketio

Express based web application to show sensor data coming from remote MQTT broker.

Table of Contents

Installation

First of all install the required packages:

 $ npm install

Configuration

  1. Rename server.js.sample to server.js:
 $ mv server.js.sample server.js
  1. 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>";

Usage

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.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

References

About

Express based web application to show sensor data coming from remote MQTT broker.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages