All Products
Search
Document Center

IoT Platform:User properties

Last Updated:Jun 15, 2023

This topic describes the user property feature of MQTT 5.0.

Background information

MQTT 5.0 packets support the property feature. You can add additional properties in the key-value format to a control packet. Multiple features of MQTT 5.0 are implemented based on the user property feature, such as session expiry, message expiry, and request-response pattern. User properties are a type of properties and similar to HTTP headers. You can configure complete custom user properties that contain UTF-8 strings in the key-value format. You can configure user properties for all MQTT 5.0 control packets, except for heartbeat packages. You can configure user properties to transmit additional custom information between devices and applications. Example:

Topic:  “sys/${productkey}/${devicename}/update”
Payload:                     "hello world!"
UserProperty: "key1_timestamp:value1_12345"
UserProperty:       "key2_msgid:value2_123"

Limits

  • You can specify up to 20 user properties.

  • IoT Platform processes only the user properties of Connect/Publish packets.

Scenarios

Message content format

You can use user properties to describe payloads. This way, a topic can support different types of payloads and you can manage devices of different batches.

image..png

Message segmentation

MQTT is suitable for scenarios in which small packets are used. MQTT 5.0 allows devices to negotiate the maximum package length with IoT Platform. If the maximum packet length cannot meet your business requirements, you can use user properties to segment packets. The following figure shows that a message is segmented into Message A and Message B when Device A sends the message. A business server identifies sub-messages by reading the user properties of the sub-messages and then combines the sub-messages. For more information, see Server-side subscription.

image..png

Message forwarding

You can use a user property to specify a type and destination for a message to be forwarded. This way, the rules engine can identify the user property and forward the message. The following figure shows how to configure the UserProperty parameter to specify a data forwarding destination when Device A submits different types of messages. For more information, see Overview.

image..png