parse

Parse an MQTT endpoint from a URI string.

Supported schemes:

  • tcp://host:port or mqtt://host:port — plain TCP (default port: 1883)

  • ssl://host:port or mqtts://host:port or tls://host:port — TCP with TLS (default port: 8883)

  • ws://host:port/path — plain WebSocket

  • wss://host:port/path — WebSocket with TLS

Example

val tcp = MqttEndpoint.parse("tcp://broker.example.com:1883")
val tls = MqttEndpoint.parse("ssl://broker.example.com:8883")
val ws = MqttEndpoint.parse("wss://broker.example.com/mqtt")

Parameters

uri

The URI to parse.

Throws

if the URI scheme is unsupported or the format is invalid.