mqtt - mqttjs/MQTT.js GitHub Wiki
Top Level API
Introduction
These methods are the preferred method for generating mqtt clients and servers.
mqtt#createServer([listener])
Create a new MqttServer (see: MqttServer)
[listener]- callback called on serverclientevent
mqtt#createSecureServer(keyPath, certPath, [listener])
Create a new MqttSecureServer
keyPath- path to private key filecertPath- path to corresponding public cert[listener]- callback called on serverclientevent
mqtt#createClient([port], [host], [options])
Create a new MqttClient (see: MqttClient)
[port]- broker port (default: 1883)[host]- broker host (default: localhost)[options]- connect options
mqtt#createSecureClient([port], [host], options)
Create a new secure MqttClient
[port]- broker port (default: 1883)[host]- broker host (default: localhost)options- connection options, must include keys:keyPath- path to private keycertPath- path to corresponding public cert
mqtt#createConnection([port], [host], [callback])
Create a new MqttConnection (see: MqttConnection)
[port]- broker port (default: 1883)[host]- broker host (default: localhost)[callback]- fired on underlying stream connect
mqtt#connect(brokerUrl, [options])
Create a new MqttClient (see: MqttClient)
The brokerUrl supports normal connections using mqtt:// or tcp:// and secure connections using mqtts:// or ssl://.
Passing the clientId is also supported, for example mqtt://user@localhost?clientId=123abc.
brokerUrl- broker Url, which is required.[options]- connect options