WebSocket transport adapter for MqttX.
This adapter uses Bandit + WebSockAdapter to serve MQTT over WebSocket (RFC 6455).
Usage
# ws://
MqttX.Server.start_link(MyHandler, handler_opts,
transport: MqttX.Transport.WebSocket,
port: 8083
)
# wss://
MqttX.Server.start_link(MyHandler, handler_opts,
transport: MqttX.Transport.WebSocket,
port: 8084,
scheme: :https,
transport_options: [certfile: "/etc/mqttx/cert.pem", keyfile: "/etc/mqttx/key.pem"]
)Options
:port- Port to listen on (default: 8083):ip- IP address to bind to (default:{0, 0, 0, 0}):path- WebSocket path (default:/mqtt):scheme-:httpforws://(default) or:httpsforwss://:transport_options- Socket options for Bandit's listener. Withscheme: :httpsthis is where the TLS configuration goes — at least:certfileand:keyfile; any:sslserver option is accepted — the same shapeMqttX.Transport.ThousandIslandtakes fortransport_module: ThousandIsland.Transports.SSL:read_timeout- Socket read timeout of the listener, in ms (default::infinity; the MQTT Keep Alive and:max_idle_timeoutclose idle connections):max_frame_size- Largest WebSocket frame accepted, in bytes (default: the packet cap plus the 14-byte frame header):check_origin- Origins a browser may connect from, as a list of"scheme://host[:port]"; any other Origin is refused with 403. A request without an Origin header passes (default:false, no check)
All protocol-level options (:max_packet_size, :max_idle_timeout,
:rate_limit, …) behave as documented in
MqttX.Transport.ThousandIsland.