Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface MqttConnectionConfig

Configuration options for an MQTT connection

Hierarchy

  • MqttConnectionConfig

Index

Properties

Optional clean_session

clean_session: boolean

Whether or not to start a clean session with each reconnect. If True, the server will forget all subscriptions with each reconnect. Set False to request that the server resume an existing session or start a new session that may be resumed after a connection loss. The session_present bool in the connection callback informs whether an existing session was successfully resumed. If an existing session is resumed, the server remembers previous subscriptions and sends mesages (with QoS1 or higher) that were published while the client was offline.

client_id

client_id: string

ID to place in CONNECT packet. Must be unique across all devices/clients. If an ID is already in use, the other client will be disconnected.

host_name

host_name: string

Server name to connect to

Optional keep_alive

keep_alive: number

The keep alive value, in seconds, to send in CONNECT packet. A PING will automatically be sent at this interval. The server will assume the connection is lost if no PING is received after 1.5X this value. This duration must be longer than timeout.

Optional password

password: string

Password to connect with

port

port: number

Server port to connect to

Optional proxy_options

proxy_options: HttpProxyOptions

Optional proxy options

socket_options

socket_options: SocketOptions

Optional socket options

Optional timeout

timeout: number

Milliseconds to wait for ping response before client assumes the connection is invalid and attempts to reconnect. This duration must be shorter than keep_alive_secs. Alternatively, TCP keep-alive via :attr:SocketOptions.keep_alive may accomplish this in a more efficient (low-power) scenario, but keep-alive options may not work the same way on every platform and OS version.

Optional tls_ctx

TLS context for secure socket connections. If None is provided, then an unencrypted connection is used.

Optional use_websocket

use_websocket: boolean

If true, connect to MQTT over websockets

Optional username

username: string

Username to connect with

Optional websocket_handshake_transform

websocket_handshake_transform: (request: HttpRequest, done: (error_code?: number) => void) => void

Optional function to transform websocket handshake request. If provided, function is called each time a websocket connection is attempted. The function may modify the HTTP request before it is sent to the server.

Type declaration

    • (request: HttpRequest, done: (error_code?: number) => void): void
    • Parameters

      • request: HttpRequest
      • done: (error_code?: number) => void
          • (error_code?: number): void
          • Parameters

            • Optional error_code: number

            Returns void

      Returns void

Optional will

will: MqttWill

Will to send with CONNECT packet. The will is published by the server when its connection to the client is unexpectedly lost.

Generated using TypeDoc