We have made a Publisher-Subscriber model using HiveMQ cloud under Node.js as a supporting technology. Using this code one can connect their MQTT devices to HiveMQ's Cloud Native IoT Messaging Broker. Run the code to see the output.
- Uses MQTT protocol to communicate with the subscribers.
- Used HiveMQ API to use MQTT protcol.
- Notifies the subscriber on E-Mail (with NodeMailer) as well as SMS (with Twilio).
- MQTT
- Twilio (For SMS and Whatsapp bot)
- Nodemailer (Mailing service)
- Clone the repository and run npm install. This will install the peer dependencies.
- Create a .env file and include the following contents:
PASSWORD=your_password_for_hivemq
PUB_PORT=your_port_number
- Run npm run pub. This establishes the subscriber.
- Run npm run sub. This establishes the publisher.
- You can test the routes on Postman.