Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface MqttBindingOptions

Options provided by the MQTT communication binding.

Hierarchy

Index

Properties

brokerUrl

brokerUrl: string

Connection Url to MQTT broker (schema protocol://host:port, e.g. mqtt://localhost:1883).

Supported protocols include mqtt, mqtts, tcp, tls, ws, wss, wx, wxs (WeChat Mini), ali, alis (Ali Mini).

remarks

You can also specify mqtt or mqtts if the Coaty agent runs in a browser: the binding will automatically open a (secure) websocket connection.

Optional connectTimeout

connectTimeout?: number

Time in milliseconds to wait for a connection acknowledgement message from the broker (optional).

Defaults to 30000 ms. If no CONNACK is received within the given time, the connection is aborted.

Optional keepalive

keepalive?: number

Keep alive interval in seconds (optional).

Defaults to 60 seconds, set to 0 to disable.

Optional logLevel

The level used to log errors, informational, as well as debug messages generated by the binding (optional).

Messages corresponding to the specified log level are emitted on the "error", "info", or "debug" event, respectively. If level is "error", only errors are emitted; if level is "info", only "error" and "info" messages are emitted; if level is "debug", all messages are emitted.

If not specified, the log level defaults to "error".

Optional namespace

namespace?: string

Namespace used to isolate different Coaty applications running with the same binding type in the same networking infrastructure (optional).

Communication events are only routed between agents within a common communication namespace: an agent publishes and observes communication events with respect to the given namespace.

If not specified (i.e. undefined), a default namespace named "-" is used.

Optional password

password?: string

The password required by your MQTT broker (optional).

Optional reconnectPeriod

reconnectPeriod?: number

Interval in milliseconds between two reconnection attempts (optional).

Defaults to 1000 ms. Disable auto reconnect by setting to 0.

Optional shouldEnableCrossNamespacing

shouldEnableCrossNamespacing?: boolean

Determines whether to enable cross-namespace communication between agents in special use cases (optional).

If true, an agent receives communication events published by any agent running with the same binding type in the same networking infrastructure, regardless of namespace.

If not specified or false, this option is not enabled.

Optional tlsOptions

tlsOptions?: { ca?: string | string[] | Buffer | Buffer[]; cert?: string | string[] | Buffer | Buffer[]; key?: string | string[] | Buffer | Buffer[] | { passphrase?: string; pem: string | Buffer }[]; passphrase?: string; pfx?: string | string[] | Buffer | Buffer[] | { buf: string | Buffer; passphrase?: string }[]; rejectUnauthorized?: boolean }

Connection options for mqtts - MQTT over TLS (optional).

Default is {}. Options are passed through to tls.connect().

remarks

If you run your MQTT connection over WebSockets, use the wsOptions instead.

Type declaration

  • [option: string]: any

    Any other option supported by tls.connect().

  • Optional ca?: string | string[] | Buffer | Buffer[]

    Optionally override the trusted CA certificates in PEM format (optional).

  • Optional cert?: string | string[] | Buffer | Buffer[]

    Cert chains in PEM format (optional).

  • Optional key?: string | string[] | Buffer | Buffer[] | { passphrase?: string; pem: string | Buffer }[]

    Private keys in PEM format (optional).

  • Optional passphrase?: string

    Shared passphrase used for a single private key and/or a PFX.

  • Optional pfx?: string | string[] | Buffer | Buffer[] | { buf: string | Buffer; passphrase?: string }[]

    PFX or PKCS12 encoded private key and certificate chain. pfx is an alternative to providing key and cert individually. PFX is usually encrypted, if it is, passphrase will be used to decrypt it.

  • Optional rejectUnauthorized?: boolean

    If not false, the server certificate is verified against the list of supplied CAs (optional). Defaults to true.

    remarks

    If you are using a self-signed certificate, additionally pass the rejectUnauthorized: false option. Beware that you are exposing yourself to man in the middle attacks, so it is a configuration that should never be used for production environments.

Optional username

username?: string

The username required by your MQTT broker (optional).

Optional wsOptions

wsOptions?: object

WebSocket specific connection options (optional).

Default is {}. Only used for WebSocket connections.

For possible options have a look at: https://github.com/websockets/ws/blob/master/doc/ws.md.

Methods

Optional transformWsUrl

  • transformWsUrl(url: string, options: any, client: any): string
  • For WebSocket ws/wss protocols only (optional). Can be used to implement signing urls or authentication options which upon reconnect can have become expired.

    For details, see here.

    Parameters

    • url: string
    • options: any
    • client: any

    Returns string

Generated using TypeDoc