mqtt-client-cli
v1.0.8
Published
MQTT Client CLI
Downloads
4
Maintainers
Readme
mqtt-client-cli
A simple MQTT Client CLI.
This library is created and maintained by Anas Aneeque
This library is written for Node.js
Written in typescript.
Features
- Connect to MQTT Server using broker url.
- Test MQTT Connections.
- Subscribe topic and receive messages.
- Publish message to topic.
Usage
Use it with CLI.
npm i -g mqtt-client-cli
mqtt-client-cli <BROKER URL>
or also you can use shorthand
mcc <BROKER URL>
Broker URL Example
protocol://user:password@host:8883/path
Subscribe to a topic
sub Hello
Now to check whether we are really subscribed, we will publish a message to Hello
pub Hello "Hello World"
Voila we received a message, output format of the recieved message is '@'
Any error occur in subscribing or publishing, a log will be received
At last, exit anytime by pressing e.
Use as a package in other nodejs app.
Install it in your project.
npm install mqtt-client-cli
Use in your project with same interface as of cli.
const { connectMQTT } = require("mqtt-client-cli");
connectMQTT("ws://localhost:1883");