Mqtt Exception
Base exception for all MQTT client errors.
Every exception thrown by MqttClient extends this type, so consumers can catch MqttException to handle any library error, or match specific subtypes for fine-grained error handling.
Example
try {
client.connect(endpoint)
} catch (e: MqttException.ConnectionRejected) {
println("Broker rejected: ${e.reasonCode}")
} catch (e: MqttException.ProtocolError) {
println("Protocol violation: ${e.message}")
} catch (e: MqttException) {
println("MQTT error: ${e.message}")
}Content copied to clipboard
Inheritors
Types
Link copied to clipboard
class ConnectionLost(reasonCode: ReasonCode, message: String, cause: Throwable? = null) : MqttException
The connection was lost unexpectedly.
Link copied to clipboard
class ConnectionRejected(reasonCode: ReasonCode, message: String, cause: Throwable? = null, val serverReference: String? = null) : MqttException
The broker rejected the CONNECT request (§3.2).
Link copied to clipboard
class ProtocolError(reasonCode: ReasonCode, message: String, cause: Throwable? = null) : MqttException
A protocol-level error occurred.