def
func:mqttPublish
mqttPublish(conn, topic, payload, cfg: {})
Publish an MQTT message to the given topic on the broker. Currently, the payload of the message must be a Str.
The following configuration options are supported:
mqttQos
: The quality-of-service to use for publishing the message. If not specified, then QoS0
is used. SeemqttQos
.mqttRetain
: Should the message be retained on the broker (true
|false
). If not specified, thenfalse
is used. SeemqttRetain
.mqttExpiryInterval
: Sets the expiry interval for the message as a Duration. This is only supported in MQTT 5.
read(@mqttConn).mqttPublish("/test", "{a: a JSON object}", {mqttQos: 2})