mixin

Funcs

Funcs : Funcs

meta mixin slots mqttPublish

Publish an MQTT message to the given topic on the broker

mqttPublish (conn: Obj, topic: Str, payload: Obj, cfg: Dict) => Obj? <admin>

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 QoS '0' is used. See mqttQos.
  • mqttRetain: Should the message be retained on the broker (true | false). If not specified, then 'false' is used. See mqttRetain.
  • mqttExpiryInterval: Sets the expiry interval for the message as a Duration. This is only supported in MQTT 5.
  • mqttUserProps: A Dict of user properties to include in the message. This is only supported in MQTT 5.
read(@mqttConn).mqttPublish("/test", "{a: a JSON object}", {mqttQos: 2, mqttExpiryInterval: 30min, mqttUserProps: {key: "value"}})

Haxall 4.0.5 ∙ 24-Feb-2026 14:33 EST