Options for the connection to broker.

interface MQTTClientOptions {
    cleanSession?: boolean;
    clientId?: string;
    host?: string;
    hosts?: string[];
    hostUri?: string;
    invocationContext?: any;
    keepAliveInterval?: number;
    mqttVersion?: 3 | 4;
    mqttVersionExplicit?: boolean;
    onFailure?: OnFailureCallback;
    onSuccess?: OnSuccessCallback;
    password?: string;
    path?: string;
    port?: number;
    ports?: number[];
    reconnect?: boolean;
    timeout?: number;
    uris?: string[];
    userName?: string;
    useSSL?: boolean;
    willMessage?: Message;
}

Hierarchy

  • ConnectionOptions
    • MQTTClientOptions

Properties

cleanSession?: boolean

If true(default) the client and server persistent state is deleted on successful connect.

true
clientId?: string

The Messaging client identifier, between 1 and 23 characters in length.

"mqtt-websocket-client"
host?: string

the address of the messaging server as a DNS name or dotted decimal IP address.

"localhost"
hosts?: string[]

If present this contains either a set of hostnames or fully qualified WebSocket URIs (ws://example.com:1883/mqtt), that are tried in order in place of the host and port paramater on the construtor. The hosts are tried one at at time in order until one of then succeeds.

hostUri?: string

The address of the messaging server as a fully qualified WebSocket URI

invocationContext?: any

Passed to the onSuccess callback or onFailure callback.

keepAliveInterval?: number

The server disconnects this client if there is no activity for this number of seconds.

The default value of 60 seconds is assumed if not set.
mqttVersion?: 3 | 4

Specifies the mqtt version to use when connecting

3 - MQTT 3.1
4 - MQTT 3.1.1 (default)
4
mqttVersionExplicit?: boolean

If set to true, will force the connection to use the selected MQTT Version or will fail to connect.

onFailure?: OnFailureCallback

Called when the connect request has failed or timed out.

onSuccess?: OnSuccessCallback

Called when the connect acknowledgement has been received from the server.

password?: string

Authentication password for this connection.

path?: string

the path on the host to connect to - only used if host is not a URI.

"/mqtt"
port?: number

The port number to connect to

9001
ports?: number[]

If present the set of ports matching the hosts. If hosts contains URIs, this property is not used.

reconnect?: boolean

Sets whether the client will automatically attempt to reconnect to the server if the connection is lost.

timeout?: number

If the connect has not succeeded within this number of seconds, it is deemed to have failed.

The default is 30 seconds.
uris?: string[]

If present, should contain a list of fully qualified WebSocket uris (e.g. ws://mqtt.eclipseprojects.io:80/mqtt), that are tried in order in place of the host and port parameter of the construtor. The uris are tried one at a time in order until one of them succeeds. Do not use this in conjunction with hosts as the hosts array will be converted to uris and will overwrite this property.

userName?: string

Authentication username for this connection.

useSSL?: boolean

If present and true, use an SSL Websocket connection.

willMessage?: Message

Sent by the server when the client disconnects abnormally.