pub struct ConnectOptions {Show 18 fields
pub host: String,
pub port: u16,
pub client_id: String,
pub version: MqttVersion,
pub clean_start: bool,
pub keep_alive_secs: u16,
pub username: Option<String>,
pub password: Option<Vec<u8>>,
pub will: Option<WillOptions>,
pub connect_timeout_secs: u32,
pub operation_timeout_secs: u32,
pub auto_reconnect: bool,
pub reconnect_backoff_secs: u32,
pub reconnect_max_backoff_secs: u32,
pub tls: Option<TlsOptions>,
pub max_packet_size: u32,
pub auth_method: Option<String>,
pub auth_data: Option<Vec<u8>>,
}Expand description
Everything needed to establish an MQTT connection.
Fields§
§host: String§port: u16§client_id: String§version: MqttVersionWhich protocol version to speak. The broker never up/downgrades a connection once CONNECT is sent.
clean_start: boolMQTT 3.1.1 “Clean Session” / MQTT 5.0 “Clean Start”.
keep_alive_secs: u16Keep-alive interval in seconds. 0 disables keep-alive pings.
username: Option<String>§password: Option<Vec<u8>>§will: Option<WillOptions>§connect_timeout_secs: u32Seconds to wait for the TCP connection + CONNACK before failing.
operation_timeout_secs: u32Seconds to wait for a QoS 1/2 handshake step per attempt before
retrying (with DUP=1) — MqttClient::publish retries an unacked
QoS 1/2 PUBLISH (or QoS 2’s PUBREL) up to 3 times before giving up,
so the worst-case total wait for a single publish() call is up to
4x this value. 0 selects the built-in default (15s).
auto_reconnect: boolIf true, crate::client::MqttClient automatically reconnects
(with exponential backoff, see Self::reconnect_backoff_secs /
Self::reconnect_max_backoff_secs) after a connection loss that
wasn’t caused by calling disconnect(), replaying every topic this
client is currently subscribed to (per its own bookkeeping) once
reconnected. Off by default — the caller must opt in.
reconnect_backoff_secs: u32Initial delay before the first reconnect attempt, doubling after
each failed attempt up to Self::reconnect_max_backoff_secs.
0 selects the built-in default (1s). Ignored unless
Self::auto_reconnect is set.
reconnect_max_backoff_secs: u32Cap on the exponential reconnect backoff delay. 0 selects the
built-in default (30s). Ignored unless Self::auto_reconnect is
set.
tls: Option<TlsOptions>If set, connect over TLS (mqtts) instead of plain TCP. None
(the default) is plain TCP, unchanged from before TLS support
existed.
max_packet_size: u32Largest packet (fixed header + body, in bytes) this client will
accept from the broker; a larger one is treated as a protocol error
and drops the connection instead of being buffered. 0 selects the
built-in default (the MQTT protocol maximum, ~256 MiB).
auth_method: Option<String>MQTT 5.0 enhanced authentication (SCRAM, Kerberos, OAuth, …): the
Authentication Method to announce in CONNECT. The broker may then
send challenges, which are answered by the
MqttAuthHandler registered with MqttClient::set_auth_handler.
Requires MqttVersion::V5.
auth_data: Option<Vec<u8>>Initial Authentication Data sent with CONNECT (e.g. a SCRAM
client-first message). Requires Self::auth_method.