WebSocketTransportFactory

class WebSocketTransportFactory(configureTls: TLSConfigBuilder.() -> Unit? = null) : MqttTransportFactory

MqttTransportFactory that builds a WebSocketTransport for MqttEndpoint.WebSocket endpoints.

Add org.meshtastic:mqtt-client-transport-ws and pass an instance to org.meshtastic.mqtt.MqttConfig.Builder.transportFactory. This is the only transport available on the browser (wasmJs) target.

To trust a broker whose certificate chain is not in the platform CA store — a private or self-signed CA — supply configureTls. The scope is this MQTT connection only, unlike Android's app-wide network_security_config.xml trust anchors:

transportFactory = WebSocketTransportFactory { trustManager = myTrustManager }

Parameters

configureTls

optional hook applied to ktor's TLSConfigBuilder for every transport this factory creates. It runs before platform trust is configured, so on Android a trust manager installed here is reached through the hostname-aware checkServerTrusted overload rather than bypassing it. Note that installing a trust manager replaces the platform's trust decision — network-security-config anchors, pinning, and Certificate Transparency policy then hold only insofar as that manager enforces them. Honoured on JVM, Android, Apple, and Linux; silently ignored on Windows (WinHttp has no TLS-config surface) and in the browser (which cannot influence trust). On Apple and Linux TLSConfigBuilder has no trustManager, so little is configurable there in practice.

Constructors

Link copied to clipboard
constructor(configureTls: TLSConfigBuilder.() -> Unit? = null)
constructor()

Functions

Link copied to clipboard
open override fun create(endpoint: MqttEndpoint): MqttTransport
Link copied to clipboard
open override fun supports(endpoint: MqttEndpoint): Boolean