WebSocket

data class WebSocket(val url: String, val protocols: List<String> = listOf("mqtt")) : MqttEndpoint

WebSocket connection, available on all platforms.

Connects via binary WebSocket frames using ktor-client-websockets. Each WebSocket frame carries exactly one complete MQTT packet. Useful for connecting through load balancers, CDNs, and firewalls that don't allow raw TCP but do allow WebSocket upgrades.

Constructors

Link copied to clipboard
constructor(url: String, protocols: List<String> = listOf("mqtt"))

Properties

Link copied to clipboard

WebSocket sub-protocols to negotiate. Default: ["mqtt"] per the MQTT specification (§6.0).

Link copied to clipboard
val url: String

The WebSocket URL (e.g. "wss://broker.example.com/mqtt"). Must not be blank. Use ws:// for unencrypted or wss:// for TLS.