mqtt
- Version 5.10.1
- Published
- 1.86 MB
- 16 dependencies
- MIT license
Install
npm i mqtt
yarn add mqtt
pnpm add mqtt
Overview
A library for the MQTT protocol
Index
Variables
Functions
Classes
MqttClient
- connect()
- connected
- defaultId()
- disconnected
- disconnecting
- end()
- endAsync()
- getLastMessageId()
- handleAuth()
- handleMessage()
- incomingStore
- keepaliveManager
- log
- messageIdProvider
- messageIdToTopic
- noop
- onKeepaliveTimeout()
- options
- outgoing
- outgoingStore
- publish()
- publishAsync()
- queue
- queueQoSZero
- reconnect()
- reconnecting
- removeOutgoingMessage()
- reschedulePing()
- sendPing()
- stream
- subscribe()
- subscribeAsync()
- unsubscribe()
- unsubscribeAsync()
- VERSION
Interfaces
IClientOptions
- auth
- authPacket
- autoAssignTopicAlias
- autoUseTopicAlias
- binary
- browserBufferSize
- browserBufferTimeout
- clean
- clientId
- connectTimeout
- createWebsocket
- customHandleAcks
- defaultProtocol
- encoding
- forceNativeWebSocket
- host
- hostname
- incomingStore
- keepalive
- log
- manualConnect
- messageIdProvider
- my
- objectMode
- outgoingStore
- password
- path
- port
- properties
- protocol
- protocolId
- protocolVersion
- query
- queueQoSZero
- reconnectPeriod
- reschedulePings
- resubscribe
- servername
- servers
- timerVariant
- transformWsUrl
- unixSocket
- username
- will
- writeCache
- wsOptions
Type Aliases
- AckHandler
- BaseMqttProtocol
- Callback
- ClientSubscribeCallback
- CloseCallback
- Constructor
- DoneCallback
- GenericCallback
- IStream
- ISubscriptionMap
- MqttProtocol
- MqttProtocolWithUnix
- OnCloseCallback
- OnConnectCallback
- OnDisconnectCallback
- OnErrorCallback
- OnMessageCallback
- OnPacketCallback
- PacketCallback
- PacketHandler
- StorePutCallback
- StreamBuilder
- TimerVariant
- VoidCallback
Namespaces
default
- AckHandler
- applyMixin()
- BaseMqttProtocol
- Callback
- Client
- ClientSubscribeCallback
- CloseCallback
- connect()
- connectAsync()
- Constructor
- DefaultMessageIdProvider
- DoneCallback
- ErrorWithReasonCode
- GenericCallback
- IClientOptions
- IClientPublishOptions
- IClientReconnectOptions
- IClientSubscribeOptions
- IClientSubscribeProperties
- IClientUnsubscribeProperties
- ISecureClientOptions
- IStore
- IStream
- ISubscriptionGrant
- ISubscriptionMap
- ISubscriptionRequest
- KeepaliveManager
- MqttClient
- MqttClientEventCallbacks
- MQTTJS_VERSION
- MqttProtocol
- MqttProtocolWithUnix
- nextTick()
- OnCloseCallback
- OnConnectCallback
- OnDisconnectCallback
- OnErrorCallback
- OnMessageCallback
- OnPacketCallback
- PacketCallback
- PacketHandler
- ReasonCodes
- Store
- StorePutCallback
- StreamBuilder
- Timer
- TimerVariant
- UniqueMessageIdProvider
- VoidCallback
Variables
variable Client
const Client: typeof MqttClient;
variable MQTTJS_VERSION
const MQTTJS_VERSION: any;
variable ReasonCodes
const ReasonCodes: { 0: string; 1: string; 2: string; 3: string; 4: string; 5: string; 16: string; 17: string; 128: string; 129: string; 130: string; 131: string; 132: string; 133: string; 134: string; 135: string; 136: string; 137: string; 138: string; 139: string; 140: string; 141: string; 142: string; 143: string; 144: string; 145: string; 146: string; 147: string; 148: string; 149: string; 150: string; 151: string; 152: string; 153: string; 154: string; 155: string; 156: string; 157: string; 158: string; 159: string; 160: string; 161: string; 162: string;};
Functions
function applyMixin
applyMixin: ( target: Constructor, mixin: Constructor, includeConstructor?: boolean) => void;
function connect
connect: { (brokerUrl: string): MqttClient; (opts: IClientOptions): MqttClient; (brokerUrl: string, opts?: IClientOptions): MqttClient;};
function connectAsync
connectAsync: { (brokerUrl: string): Promise<MqttClient>; (opts: IClientOptions): Promise<MqttClient>; (brokerUrl: string, opts?: IClientOptions): Promise<MqttClient>; ( brokerUrl: string, opts: IClientOptions, allowRetries: boolean ): Promise<MqttClient>;};
function nextTick
nextTick: (callback: Function, ...args: any[]) => void;
Classes
class DefaultMessageIdProvider
class DefaultMessageIdProvider implements IMessageIdProvider {}
constructor
constructor();
method allocate
allocate: () => number;
method clear
clear: () => void;
method deallocate
deallocate: (messageId: number) => void;
method getLastAllocated
getLastAllocated: () => number;
method register
register: (messageId: number) => boolean;
class ErrorWithReasonCode
class ErrorWithReasonCode extends Error {}
constructor
constructor(message: string, code: number);
property code
code: number;
class KeepaliveManager
class KeepaliveManager {}
constructor
constructor(client: MqttClient, variant: TimerVariant | Timer);
property intervalEvery
readonly intervalEvery: number;
property keepalive
readonly keepalive: number;
property keepaliveTimeoutTimestamp
readonly keepaliveTimeoutTimestamp: number;
method destroy
destroy: () => void;
method reschedule
reschedule: () => void;
method setKeepalive
setKeepalive: (value: number) => void;
class MqttClient
class MqttClient extends TypedEventEmitter<MqttClientEventCallbacks> {}
constructor
constructor(streamBuilder: StreamBuilder, options: IClientOptions);
property connected
connected: boolean;
property disconnected
disconnected: boolean;
property disconnecting
disconnecting: boolean;
property incomingStore
incomingStore: IStore;
property keepaliveManager
keepaliveManager: KeepaliveManager;
property log
log: (...args: any[]) => void;
property messageIdProvider
messageIdProvider: IMessageIdProvider;
property messageIdToTopic
messageIdToTopic: Record<number, string[]>;
property noop
noop: (error?: any) => void;
property options
options: IClientOptions;
property outgoing
outgoing: Record< number, { volatile: boolean; cb: (err: Error, packet?: Packet) => void }>;
property outgoingStore
outgoingStore: IStore;
property queue
queue: { packet: Packet; cb: PacketCallback }[];
property queueQoSZero
queueQoSZero: boolean;
property reconnecting
reconnecting: boolean;
property stream
stream: any;
property VERSION
static VERSION: any;
method connect
connect: () => this;
method defaultId
static defaultId: () => string;
method end
end: { (cb?: DoneCallback): MqttClient; (force?: boolean): MqttClient; (opts?: IDisconnectPacket, cb?: DoneCallback): MqttClient; (force?: boolean, cb?: DoneCallback): MqttClient; (force?: boolean, opts?: IDisconnectPacket, cb?: DoneCallback): MqttClient;};
method endAsync
endAsync: { (): Promise<void>; (force?: boolean): Promise<void>; (opts?: IDisconnectPacket): Promise<void>; (force?: boolean, opts?: IDisconnectPacket): Promise<void>;};
method getLastMessageId
getLastMessageId: () => number;
method handleAuth
handleAuth: (packet: IAuthPacket, callback: PacketCallback) => void;
method handleMessage
handleMessage: (packet: IPublishPacket, callback: DoneCallback) => void;
method onKeepaliveTimeout
onKeepaliveTimeout: () => void;
method publish
publish: { (topic: string, message: string | Buffer): MqttClient; (topic: string, message: any, callback?: PacketCallback): MqttClient; ( topic: string, message: any, opts?: IClientPublishOptions, callback?: PacketCallback ): MqttClient;};
method publishAsync
publishAsync: { (topic: string, message: string | Buffer): Promise<Packet | undefined>; (topic: string, message: any, opts?: IClientPublishOptions): Promise<any>;};
method reconnect
reconnect: ( opts?: Pick<IClientOptions, 'incomingStore' | 'outgoingStore'>) => MqttClient;
method removeOutgoingMessage
removeOutgoingMessage: (messageId: number) => MqttClient;
method reschedulePing
reschedulePing: (force?: boolean) => void;
method sendPing
sendPing: () => void;
method subscribe
subscribe: { (topicObject: string | string[] | ISubscriptionMap): MqttClient; ( topicObject: string | string[] | ISubscriptionMap, callback?: ClientSubscribeCallback ): MqttClient; ( topicObject: string | string[] | ISubscriptionMap, opts?: IClientSubscribeOptions | IClientSubscribeProperties ): MqttClient; ( topicObject: string | string[] | ISubscriptionMap, opts?: IClientSubscribeOptions | IClientSubscribeProperties, callback?: ClientSubscribeCallback ): MqttClient;};
method subscribeAsync
subscribeAsync: { (topicObject: string | string[] | ISubscriptionMap): Promise< ISubscriptionGrant[] >; ( topicObject: string | string[] | ISubscriptionMap, opts?: IClientSubscribeOptions | IClientSubscribeProperties ): Promise<ISubscriptionGrant[]>;};
method unsubscribe
unsubscribe: { (topic: string | string[]): MqttClient; (topic: string | string[], opts?: IClientUnsubscribeProperties): MqttClient; (topic: string | string[], callback?: PacketCallback): MqttClient; ( topic: string | string[], opts?: IClientUnsubscribeProperties, callback?: PacketCallback ): MqttClient;};
method unsubscribeAsync
unsubscribeAsync: { (topic: string | string[]): Promise<Packet | undefined>; ( topic: string | string[], opts?: IClientUnsubscribeProperties ): Promise<any>;};
class Store
class Store implements IStore {}
constructor
constructor(options?: IStoreOptions);
method close
close: (cb: DoneCallback) => void;
method createStream
createStream: () => Readable;
method del
del: (packet: Pick<Packet, 'messageId'>, cb: PacketCallback) => this;
method get
get: (packet: Pick<Packet, 'messageId'>, cb: PacketCallback) => this;
method put
put: (packet: Packet, cb: DoneCallback) => this;
class UniqueMessageIdProvider
class UniqueMessageIdProvider implements IMessageIdProvider {}
constructor
constructor();
method allocate
allocate: () => number;
method clear
clear: () => void;
method deallocate
deallocate: (messageId: number) => void;
method getLastAllocated
getLastAllocated: () => number;
method register
register: (messageId: number) => boolean;
Interfaces
interface IClientOptions
interface IClientOptions extends ISecureClientOptions {}
property auth
auth?: string;
property authPacket
authPacket?: Partial<IAuthPacket>;
property autoAssignTopicAlias
autoAssignTopicAlias?: boolean;
property autoUseTopicAlias
autoUseTopicAlias?: boolean;
property binary
binary?: boolean;
property browserBufferSize
browserBufferSize?: number;
property browserBufferTimeout
browserBufferTimeout?: number;
property clean
clean?: boolean;
property clientId
clientId?: string;
property connectTimeout
connectTimeout?: number;
property createWebsocket
createWebsocket?: ( url: string, websocketSubProtocols: string[], options: IClientOptions) => any;
property customHandleAcks
customHandleAcks?: AckHandler;
property defaultProtocol
defaultProtocol?: MqttProtocol;
property encoding
encoding?: BufferEncoding;
property forceNativeWebSocket
forceNativeWebSocket?: boolean;
property host
host?: string;
property hostname
hostname?: string;
property incomingStore
incomingStore?: IStore;
property keepalive
keepalive?: number;
property log
log?: (...args: any[]) => void;
property manualConnect
manualConnect?: boolean;
property messageIdProvider
messageIdProvider?: IMessageIdProvider;
property my
my?: any;
property objectMode
objectMode?: boolean;
property outgoingStore
outgoingStore?: IStore;
property password
password?: Buffer | string;
property path
path?: string;
property port
port?: number;
property properties
properties?: IConnectPacket['properties'];
property protocol
protocol?: MqttProtocol;
property protocolId
protocolId?: IConnectPacket['protocolId'];
property protocolVersion
protocolVersion?: IConnectPacket['protocolVersion'];
property query
query?: Record<string, string>;
property queueQoSZero
queueQoSZero?: boolean;
property reconnectPeriod
reconnectPeriod?: number;
property reschedulePings
reschedulePings?: boolean;
property resubscribe
resubscribe?: boolean;
property servername
servername?: string;
property servers
servers?: Array<{ host: string; port: number; protocol?: 'wss' | 'ws' | 'mqtt' | 'mqtts' | 'tcp' | 'ssl' | 'wx' | 'wxs';}>;
property timerVariant
timerVariant?: TimerVariant | Timer;
property transformWsUrl
transformWsUrl?: ( url: string, options: IClientOptions, client: MqttClient) => string;
property unixSocket
unixSocket?: boolean;
property username
username?: string;
property will
will?: IConnectPacket['will'];
property writeCache
writeCache?: boolean;
property wsOptions
wsOptions?: ClientOptions | ClientRequestArgs | DuplexOptions;
interface IClientPublishOptions
interface IClientPublishOptions {}
property cbStorePut
cbStorePut?: StorePutCallback;
property dup
dup?: boolean;
property properties
properties?: IPublishPacket['properties'];
property qos
qos?: QoS;
property retain
retain?: boolean;
interface IClientReconnectOptions
interface IClientReconnectOptions {}
property incomingStore
incomingStore?: Store;
property outgoingStore
outgoingStore?: Store;
interface IClientSubscribeOptions
interface IClientSubscribeOptions extends IClientSubscribeProperties {}
interface IClientSubscribeProperties
interface IClientSubscribeProperties {}
property properties
properties?: ISubscribePacket['properties'];
interface IClientUnsubscribeProperties
interface IClientUnsubscribeProperties {}
property properties
properties?: IUnsubscribePacket['properties'];
interface ISecureClientOptions
interface ISecureClientOptions {}
property ALPNProtocols
ALPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array;
property ca
ca?: string | string[] | Buffer | Buffer[];
property caPaths
caPaths?: string | string[];
property cert
cert?: string | string[] | Buffer | Buffer[];
property certPath
certPath?: string;
property key
key?: string | string[] | Buffer | Buffer[] | any[];
property keyPath
keyPath?: string;
property rejectUnauthorized
rejectUnauthorized?: boolean;
interface IStore
interface IStore {}
method close
close: (cb: DoneCallback) => void;
method createStream
createStream: () => Readable;
method del
del: (packet: Pick<Packet, 'messageId'>, cb: PacketCallback) => IStore;
method get
get: (packet: Pick<Packet, 'messageId'>, cb: PacketCallback) => IStore;
method put
put: (packet: Packet, cb: DoneCallback) => IStore;
interface ISubscriptionGrant
interface ISubscriptionGrant extends Omit<ISubscriptionRequest, 'qos' | 'properties'> {}
property qos
qos: QoS | 128;
interface ISubscriptionRequest
interface ISubscriptionRequest extends IClientSubscribeOptions {}
property topic
topic: string;
interface MqttClientEventCallbacks
interface MqttClientEventCallbacks {}
property close
close: OnCloseCallback;
property connect
connect: OnConnectCallback;
property disconnect
disconnect: OnDisconnectCallback;
property end
end: VoidCallback;
property error
error: OnErrorCallback;
property message
message: OnMessageCallback;
property offline
offline: VoidCallback;
property outgoingEmpty
outgoingEmpty: VoidCallback;
property packetreceive
packetreceive: OnPacketCallback;
property packetsend
packetsend: OnPacketCallback;
property reconnect
reconnect: VoidCallback;
Type Aliases
type AckHandler
type AckHandler = ( topic: string, message: Buffer, packet: any, cb: (error: Error | number, code?: number) => void) => void;
type BaseMqttProtocol
type BaseMqttProtocol = | 'wss' | 'ws' | 'mqtt' | 'mqtts' | 'tcp' | 'ssl' | 'wx' | 'wxs' | 'ali' | 'alis';
type Callback
type Callback = () => void;
type ClientSubscribeCallback
type ClientSubscribeCallback = ( err: Error | null, granted?: ISubscriptionGrant[], packet?: ISubackPacket) => void;
type CloseCallback
type CloseCallback = (error?: Error) => void;
type Constructor
type Constructor<T = {}> = new (...args: any[]) => T;
type DoneCallback
type DoneCallback = (error?: Error) => void;
type GenericCallback
type GenericCallback<T> = (error?: Error, result?: T) => void;
type IStream
type IStream = Duplex & { socket?: any;};
type ISubscriptionMap
type ISubscriptionMap = { [topic: string]: IClientSubscribeOptions;} & { resubscribe?: boolean;};
type MqttProtocol
type MqttProtocol = BaseMqttProtocol | MqttProtocolWithUnix;
type MqttProtocolWithUnix
type MqttProtocolWithUnix = `${BaseMqttProtocol}+unix`;
type OnCloseCallback
type OnCloseCallback = () => void;
type OnConnectCallback
type OnConnectCallback = (packet: IConnackPacket) => void;
type OnDisconnectCallback
type OnDisconnectCallback = (packet: IDisconnectPacket) => void;
type OnErrorCallback
type OnErrorCallback = (error: Error | ErrorWithReasonCode) => void;
type OnMessageCallback
type OnMessageCallback = ( topic: string, payload: Buffer, packet: IPublishPacket) => void;
type OnPacketCallback
type OnPacketCallback = (packet: Packet) => void;
type PacketCallback
type PacketCallback = (error?: Error | ErrorWithReasonCode, packet?: Packet) => any;
type PacketHandler
type PacketHandler = ( client: MqttClient, packet: Packet, done?: DoneCallback) => void;
type StorePutCallback
type StorePutCallback = () => void;
type StreamBuilder
type StreamBuilder = (client: MqttClient, opts?: IClientOptions) => IStream;
type TimerVariant
type TimerVariant = 'auto' | 'worker' | 'native';
type VoidCallback
type VoidCallback = () => void;
Namespaces
namespace default
module 'build/mqtt.d.ts' {}
variable Client
const Client: typeof MqttClient;
variable MQTTJS_VERSION
const MQTTJS_VERSION: any;
variable ReasonCodes
const ReasonCodes: { 0: string; 1: string; 2: string; 3: string; 4: string; 5: string; 16: string; 17: string; 128: string; 129: string; 130: string; 131: string; 132: string; 133: string; 134: string; 135: string; 136: string; 137: string; 138: string; 139: string; 140: string; 141: string; 142: string; 143: string; 144: string; 145: string; 146: string; 147: string; 148: string; 149: string; 150: string; 151: string; 152: string; 153: string; 154: string; 155: string; 156: string; 157: string; 158: string; 159: string; 160: string; 161: string; 162: string;};
function applyMixin
applyMixin: ( target: Constructor, mixin: Constructor, includeConstructor?: boolean) => void;
function connect
connect: { (brokerUrl: string): MqttClient; (opts: IClientOptions): MqttClient; (brokerUrl: string, opts?: IClientOptions): MqttClient;};
function connectAsync
connectAsync: { (brokerUrl: string): Promise<MqttClient>; (opts: IClientOptions): Promise<MqttClient>; (brokerUrl: string, opts?: IClientOptions): Promise<MqttClient>; ( brokerUrl: string, opts: IClientOptions, allowRetries: boolean ): Promise<MqttClient>;};
function nextTick
nextTick: (callback: Function, ...args: any[]) => void;
class DefaultMessageIdProvider
class DefaultMessageIdProvider implements IMessageIdProvider {}
constructor
constructor();
method allocate
allocate: () => number;
method clear
clear: () => void;
method deallocate
deallocate: (messageId: number) => void;
method getLastAllocated
getLastAllocated: () => number;
method register
register: (messageId: number) => boolean;
class ErrorWithReasonCode
class ErrorWithReasonCode extends Error {}
constructor
constructor(message: string, code: number);
property code
code: number;
class KeepaliveManager
class KeepaliveManager {}
constructor
constructor(client: MqttClient, variant: TimerVariant | Timer);
property intervalEvery
readonly intervalEvery: number;
property keepalive
readonly keepalive: number;
property keepaliveTimeoutTimestamp
readonly keepaliveTimeoutTimestamp: number;
method destroy
destroy: () => void;
method reschedule
reschedule: () => void;
method setKeepalive
setKeepalive: (value: number) => void;
class MqttClient
class MqttClient extends TypedEventEmitter<MqttClientEventCallbacks> {}
constructor
constructor(streamBuilder: StreamBuilder, options: IClientOptions);
property connected
connected: boolean;
property disconnected
disconnected: boolean;
property disconnecting
disconnecting: boolean;
property incomingStore
incomingStore: IStore;
property keepaliveManager
keepaliveManager: KeepaliveManager;
property log
log: (...args: any[]) => void;
property messageIdProvider
messageIdProvider: IMessageIdProvider;
property messageIdToTopic
messageIdToTopic: Record<number, string[]>;
property noop
noop: (error?: any) => void;
property options
options: IClientOptions;
property outgoing
outgoing: Record< number, { volatile: boolean; cb: (err: Error, packet?: Packet) => void }>;
property outgoingStore
outgoingStore: IStore;
property queue
queue: { packet: Packet; cb: PacketCallback }[];
property queueQoSZero
queueQoSZero: boolean;
property reconnecting
reconnecting: boolean;
property stream
stream: any;
property VERSION
static VERSION: any;
method connect
connect: () => this;
method defaultId
static defaultId: () => string;
method end
end: { (cb?: DoneCallback): MqttClient; (force?: boolean): MqttClient; (opts?: IDisconnectPacket, cb?: DoneCallback): MqttClient; (force?: boolean, cb?: DoneCallback): MqttClient; (force?: boolean, opts?: IDisconnectPacket, cb?: DoneCallback): MqttClient;};
method endAsync
endAsync: { (): Promise<void>; (force?: boolean): Promise<void>; (opts?: IDisconnectPacket): Promise<void>; (force?: boolean, opts?: IDisconnectPacket): Promise<void>;};
method getLastMessageId
getLastMessageId: () => number;
method handleAuth
handleAuth: (packet: IAuthPacket, callback: PacketCallback) => void;
method handleMessage
handleMessage: (packet: IPublishPacket, callback: DoneCallback) => void;
method onKeepaliveTimeout
onKeepaliveTimeout: () => void;
method publish
publish: { (topic: string, message: string | Buffer): MqttClient; (topic: string, message: any, callback?: PacketCallback): MqttClient; ( topic: string, message: any, opts?: IClientPublishOptions, callback?: PacketCallback ): MqttClient;};
method publishAsync
publishAsync: { (topic: string, message: string | Buffer): Promise<Packet | undefined>; (topic: string, message: any, opts?: IClientPublishOptions): Promise<any>;};
method reconnect
reconnect: ( opts?: Pick<IClientOptions, 'incomingStore' | 'outgoingStore'>) => MqttClient;
method removeOutgoingMessage
removeOutgoingMessage: (messageId: number) => MqttClient;
method reschedulePing
reschedulePing: (force?: boolean) => void;
method sendPing
sendPing: () => void;
method subscribe
subscribe: { (topicObject: string | string[] | ISubscriptionMap): MqttClient; ( topicObject: string | string[] | ISubscriptionMap, callback?: ClientSubscribeCallback ): MqttClient; ( topicObject: string | string[] | ISubscriptionMap, opts?: IClientSubscribeOptions | IClientSubscribeProperties ): MqttClient; ( topicObject: string | string[] | ISubscriptionMap, opts?: IClientSubscribeOptions | IClientSubscribeProperties, callback?: ClientSubscribeCallback ): MqttClient;};
method subscribeAsync
subscribeAsync: { (topicObject: string | string[] | ISubscriptionMap): Promise< ISubscriptionGrant[] >; ( topicObject: string | string[] | ISubscriptionMap, opts?: IClientSubscribeOptions | IClientSubscribeProperties ): Promise<ISubscriptionGrant[]>;};
method unsubscribe
unsubscribe: { (topic: string | string[]): MqttClient; (topic: string | string[], opts?: IClientUnsubscribeProperties): MqttClient; (topic: string | string[], callback?: PacketCallback): MqttClient; ( topic: string | string[], opts?: IClientUnsubscribeProperties, callback?: PacketCallback ): MqttClient;};
method unsubscribeAsync
unsubscribeAsync: { (topic: string | string[]): Promise<Packet | undefined>; ( topic: string | string[], opts?: IClientUnsubscribeProperties ): Promise<any>;};
class Store
class Store implements IStore {}
constructor
constructor(options?: IStoreOptions);
method close
close: (cb: DoneCallback) => void;
method createStream
createStream: () => Readable;
method del
del: (packet: Pick<Packet, 'messageId'>, cb: PacketCallback) => this;
method get
get: (packet: Pick<Packet, 'messageId'>, cb: PacketCallback) => this;
method put
put: (packet: Packet, cb: DoneCallback) => this;
class UniqueMessageIdProvider
class UniqueMessageIdProvider implements IMessageIdProvider {}
constructor
constructor();
method allocate
allocate: () => number;
method clear
clear: () => void;
method deallocate
deallocate: (messageId: number) => void;
method getLastAllocated
getLastAllocated: () => number;
method register
register: (messageId: number) => boolean;
interface IClientOptions
interface IClientOptions extends ISecureClientOptions {}
property auth
auth?: string;
property authPacket
authPacket?: Partial<IAuthPacket>;
property autoAssignTopicAlias
autoAssignTopicAlias?: boolean;
property autoUseTopicAlias
autoUseTopicAlias?: boolean;
property binary
binary?: boolean;
property browserBufferSize
browserBufferSize?: number;
property browserBufferTimeout
browserBufferTimeout?: number;
property clean
clean?: boolean;
property clientId
clientId?: string;
property connectTimeout
connectTimeout?: number;
property createWebsocket
createWebsocket?: ( url: string, websocketSubProtocols: string[], options: IClientOptions) => any;
property customHandleAcks
customHandleAcks?: AckHandler;
property defaultProtocol
defaultProtocol?: MqttProtocol;
property encoding
encoding?: BufferEncoding;
property forceNativeWebSocket
forceNativeWebSocket?: boolean;
property host
host?: string;
property hostname
hostname?: string;
property incomingStore
incomingStore?: IStore;
property keepalive
keepalive?: number;
property log
log?: (...args: any[]) => void;
property manualConnect
manualConnect?: boolean;
property messageIdProvider
messageIdProvider?: IMessageIdProvider;
property my
my?: any;
property objectMode
objectMode?: boolean;
property outgoingStore
outgoingStore?: IStore;
property password
password?: Buffer | string;
property path
path?: string;
property port
port?: number;
property properties
properties?: IConnectPacket['properties'];
property protocol
protocol?: MqttProtocol;
property protocolId
protocolId?: IConnectPacket['protocolId'];
property protocolVersion
protocolVersion?: IConnectPacket['protocolVersion'];
property query
query?: Record<string, string>;
property queueQoSZero
queueQoSZero?: boolean;
property reconnectPeriod
reconnectPeriod?: number;
property reschedulePings
reschedulePings?: boolean;
property resubscribe
resubscribe?: boolean;
property servername
servername?: string;
property servers
servers?: Array<{ host: string; port: number; protocol?: 'wss' | 'ws' | 'mqtt' | 'mqtts' | 'tcp' | 'ssl' | 'wx' | 'wxs';}>;
property timerVariant
timerVariant?: TimerVariant | Timer;
property transformWsUrl
transformWsUrl?: ( url: string, options: IClientOptions, client: MqttClient) => string;
property unixSocket
unixSocket?: boolean;
property username
username?: string;
property will
will?: IConnectPacket['will'];
property writeCache
writeCache?: boolean;
property wsOptions
wsOptions?: ClientOptions | ClientRequestArgs | DuplexOptions;
interface IClientPublishOptions
interface IClientPublishOptions {}
property cbStorePut
cbStorePut?: StorePutCallback;
property dup
dup?: boolean;
property properties
properties?: IPublishPacket['properties'];
property qos
qos?: QoS;
property retain
retain?: boolean;
interface IClientReconnectOptions
interface IClientReconnectOptions {}
property incomingStore
incomingStore?: Store;
property outgoingStore
outgoingStore?: Store;
interface IClientSubscribeOptions
interface IClientSubscribeOptions extends IClientSubscribeProperties {}
interface IClientSubscribeProperties
interface IClientSubscribeProperties {}
property properties
properties?: ISubscribePacket['properties'];
interface IClientUnsubscribeProperties
interface IClientUnsubscribeProperties {}
property properties
properties?: IUnsubscribePacket['properties'];
interface ISecureClientOptions
interface ISecureClientOptions {}
property ALPNProtocols
ALPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array;
property ca
ca?: string | string[] | Buffer | Buffer[];
property caPaths
caPaths?: string | string[];
property cert
cert?: string | string[] | Buffer | Buffer[];
property certPath
certPath?: string;
property key
key?: string | string[] | Buffer | Buffer[] | any[];
property keyPath
keyPath?: string;
property rejectUnauthorized
rejectUnauthorized?: boolean;
interface IStore
interface IStore {}
method close
close: (cb: DoneCallback) => void;
method createStream
createStream: () => Readable;
method del
del: (packet: Pick<Packet, 'messageId'>, cb: PacketCallback) => IStore;
method get
get: (packet: Pick<Packet, 'messageId'>, cb: PacketCallback) => IStore;
method put
put: (packet: Packet, cb: DoneCallback) => IStore;
interface ISubscriptionGrant
interface ISubscriptionGrant extends Omit<ISubscriptionRequest, 'qos' | 'properties'> {}
property qos
qos: QoS | 128;
interface ISubscriptionRequest
interface ISubscriptionRequest extends IClientSubscribeOptions {}
property topic
topic: string;
interface MqttClientEventCallbacks
interface MqttClientEventCallbacks {}
property close
close: OnCloseCallback;
property connect
connect: OnConnectCallback;
property disconnect
disconnect: OnDisconnectCallback;
property end
end: VoidCallback;
property error
error: OnErrorCallback;
property message
message: OnMessageCallback;
property offline
offline: VoidCallback;
property outgoingEmpty
outgoingEmpty: VoidCallback;
property packetreceive
packetreceive: OnPacketCallback;
property packetsend
packetsend: OnPacketCallback;
property reconnect
reconnect: VoidCallback;
type AckHandler
type AckHandler = ( topic: string, message: Buffer, packet: any, cb: (error: Error | number, code?: number) => void) => void;
type BaseMqttProtocol
type BaseMqttProtocol = | 'wss' | 'ws' | 'mqtt' | 'mqtts' | 'tcp' | 'ssl' | 'wx' | 'wxs' | 'ali' | 'alis';
type Callback
type Callback = () => void;
type ClientSubscribeCallback
type ClientSubscribeCallback = ( err: Error | null, granted?: ISubscriptionGrant[], packet?: ISubackPacket) => void;
type CloseCallback
type CloseCallback = (error?: Error) => void;
type Constructor
type Constructor<T = {}> = new (...args: any[]) => T;
type DoneCallback
type DoneCallback = (error?: Error) => void;
type GenericCallback
type GenericCallback<T> = (error?: Error, result?: T) => void;
type IStream
type IStream = Duplex & { socket?: any;};
type ISubscriptionMap
type ISubscriptionMap = { [topic: string]: IClientSubscribeOptions;} & { resubscribe?: boolean;};
type MqttProtocol
type MqttProtocol = BaseMqttProtocol | MqttProtocolWithUnix;
type MqttProtocolWithUnix
type MqttProtocolWithUnix = `${BaseMqttProtocol}+unix`;
type OnCloseCallback
type OnCloseCallback = () => void;
type OnConnectCallback
type OnConnectCallback = (packet: IConnackPacket) => void;
type OnDisconnectCallback
type OnDisconnectCallback = (packet: IDisconnectPacket) => void;
type OnErrorCallback
type OnErrorCallback = (error: Error | ErrorWithReasonCode) => void;
type OnMessageCallback
type OnMessageCallback = ( topic: string, payload: Buffer, packet: IPublishPacket) => void;
type OnPacketCallback
type OnPacketCallback = (packet: Packet) => void;
type PacketCallback
type PacketCallback = (error?: Error | ErrorWithReasonCode, packet?: Packet) => any;
type PacketHandler
type PacketHandler = ( client: MqttClient, packet: Packet, done?: DoneCallback) => void;
type StorePutCallback
type StorePutCallback = () => void;
type StreamBuilder
type StreamBuilder = (client: MqttClient, opts?: IClientOptions) => IStream;
type TimerVariant
type TimerVariant = 'auto' | 'worker' | 'native';
type VoidCallback
type VoidCallback = () => void;
Package Files (11)
Dependencies (16)
Dev Dependencies (41)
- @esm-bundle/chai
- @release-it/conventional-changelog
- @types/chai
- @types/node
- @types/sinon
- @types/tape
- @typescript-eslint/eslint-plugin
- @typescript-eslint/parser
- @web/test-runner
- @web/test-runner-playwright
- aedes-cli
- chai
- chokidar
- codecov
- conventional-changelog-cli
- end-of-stream
- esbuild
- esbuild-plugin-polyfill-node
- esbuild-register
- eslint
- eslint-config-airbnb-base
- eslint-config-airbnb-typescript
- eslint-config-prettier
- eslint-plugin-import
- eslint-plugin-prettier
- global
- leaked-handles
- mkdirp
- mqtt-connection
- mqtt-level-store
- nyc
- pre-commit
- prettier
- release-it
- rimraf
- should
- sinon
- snazzy
- tape
- ts-node
- typescript
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/mqtt
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/mqtt)
- HTML<a href="https://www.jsdocs.io/package/mqtt"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 7635 ms. - Missing or incorrect documentation? Open an issue for this package.