Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mqtt-packet

Package Overview
Dependencies
Maintainers
2
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mqtt-packet

Parse and generate MQTT packets like a breeze

  • 6.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
790K
decreased by-10.68%
Maintainers
2
Weekly downloads
 
Created

What is mqtt-packet?

The mqtt-packet npm package is a utility for encoding and decoding packets used in MQTT (Message Queuing Telemetry Transport), which is a lightweight messaging protocol for small sensors and mobile devices. It is designed for connections with remote locations where a small code footprint is required and/or network bandwidth is at a premium.

What are mqtt-packet's main functionalities?

Parsing MQTT Packets

This feature allows you to parse MQTT packets from a buffer. The code sample demonstrates how to create a parser instance, listen for 'packet' events, and parse a buffer containing an MQTT packet.

const mqttPacket = require('mqtt-packet');
const parser = mqttPacket.parser();
parser.on('packet', function(packet) {
  console.log(packet);
});
parser.parse(Buffer.from([0x30, 0x02, 0x00, 0x00]));

Generating MQTT Packets

This feature allows you to generate MQTT packets. The code sample shows how to create an MQTT packet object and then generate a buffer that can be sent over a network.

const mqttPacket = require('mqtt-packet');
const packet = {
  cmd: 'publish',
  messageId: 42,
  topic: 'test/topic',
  payload: 'test payload',
  qos: 0,
  retain: false
};
const buffer = mqttPacket.generate(packet);
console.log(buffer);

Other packages similar to mqtt-packet

Keywords

FAQs

Package last updated on 21 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc