mqtt-client-cli
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

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

Usage Example

Subscribe to a topic

sub Hello

Subscribe Example

Now to check whether we are really subscribed, we will publish a message to Hello

pub Hello "Hello World"

Publish Example

Voila we received a message, output format of the recieved message is '@'

Any error occur in subscribing or publishing, a log will be received

Error Example

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");

Support

Buy Me A Coffee

Package Sidebar

Install

npm i mqtt-client-cli

Weekly Downloads

0

Version

1.0.8

License

ISC

Unpacked Size

29.9 kB

Total Files

9

Last publish

Collaborators

  • anasnew99