Arlo Guthrie
Arlo Guthrie

Reputation: 1234

MQTT version 5 publish properties in paho.mqtt.golang?

I was reviewing MQTT v5 differences and noticed that "header" information can be published outside the body of the message with user properties. Is there support for this in paho.mqtt.golang? Looking at the Publish function, there is only support for client.Publish(topic, qos, retain, message_bytes).

Upvotes: 0

Views: 1829

Answers (1)

Brits
Brits

Reputation: 18315

paho.mqtt.golang only supports MQTT 3/3.1. If you want properties, which were introduced in v5, take a look at paho.golang which is a total rewrite that supports MQTT v5 (and v5 only). Support for properties is demonstrated in the chat example:

pb := &paho.Publish{
            Topic:   *topic,
            QoS:     byte(*qos),
            Payload: []byte(message),
            Properties: &paho.PublishProperties{
                User: map[string]string{
                    "chatname": *name,
                },
            },
        }

Note that while paho.golang is fairly stable it does not offer the same level of functionality as paho.mqtt.golang (for example persistence; see this issue for more info).

Upvotes: 5

Related Questions