https://github.com/anasnew99/mqtt-cli
Simple MQTT CLI Created in NodeJS
https://github.com/anasnew99/mqtt-cli
cli mqtt mqtt-cli mqtt-client pubsub
Last synced: 27 days ago
JSON representation
Simple MQTT CLI Created in NodeJS
- Host: GitHub
- URL: https://github.com/anasnew99/mqtt-cli
- Owner: Anasnew99
- License: mit
- Created: 2021-12-04T18:14:23.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-12-05T08:47:45.000Z (over 3 years ago)
- Last Synced: 2025-04-07T05:34:38.545Z (27 days ago)
- Topics: cli, mqtt, mqtt-cli, mqtt-client, pubsub
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/mqtt-client-cli
- Size: 194 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [mqtt-client-cli](https://github.com/Anasnew99/mqtt-cli)
> A simple MQTT Client CLI.
> This library is created and maintained by [Anas Aneeque](https://www.linkedin.com/in/anasnew99/)
> 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
```or also you can use shorthand
```
mcc
```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.
```js
const { connectMQTT } = require("mqtt-client-cli");
connectMQTT("ws://localhost:1883");
```# Support