Skip to content

Latest commit

 

History

History
39 lines (31 loc) · 1.27 KB

File metadata and controls

39 lines (31 loc) · 1.27 KB

MQTT input stream

NPM version

MQTT input stream provides an easy wrapper around MQTT.js for mutator-io.

Installation

npm i mutator-io-plugin-in-mqtt

The configuration required is exactly the same, with the except of a new keyword called topics that will indicate which topics this instance should subscribe to.

import { IClientOptions } from 'mqtt/types'

interface Config extends IClientOptions {
  topics: string[]
}

TLS support

This kind of security is supported just like it is in MQTT.js (though there aren't many examples around)

import * as MqttInputStream from 'mutator-io-plugin-in-mqtt'

const myInputStream = new MqttInputStream({
  protocol: 'mqtts',
  host: 'my-endpoint.iot.eu-central-1.amazonaws.com',
  port: 8883,
  key: fs.readFileSync('./certs/mqtt.key'),
  cert: fs.readFileSync('./certs/mqtt.pem'),
  ca: fs.readFileSync('./certs/mqtt_ca.pem'),
  requestCert: true,
  rejectUnauthorized: true,
  topics: ['something/+/+/+/status/+/+/+']
} as MqttInputStream.Config)