Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What's New in MQTT 5.0 (3) | payload identification and content type

Shulou Source: shulou.com Published: 2022-06-03 01:09:21 10月04日 Update

Payload identification (Payload Format Indicator)

Of all the message types of MQTT 5.0, this attribute exists only in the testamentary attributes of PUBLISH messages and CONNECT messages.

The payload identification occupies only one byte size, and it has only 0 (0x00) and 1 (0x01) values.

In the MQTT CONNECT message, when the value of the payload identification of the testamentary attribute is 0, it means that the testamentary message is an undetermined byte. When the attribute value is 1, it means that the testamentary message is UTF-8-encoded character data, and the data in the testamentary payload (Will Payload) must conform to the definition of the standard UTF-8.

In the MQTT PUBLISH message, when the value of the payload identification of the PUBLISH attribute is 0, it means that the PUBLISH message is an undetermined byte. When the attribute value is 1, it means that the payload of the PUBLISH message is UTF-8-encoded character data, and the data in the PUBLISH message payload (Payload) must conform to the definition of the standard UTF-8.

Content type (Content Type)

Of all the message types of MQTT 5.0, this attribute also exists only in the testamentary attributes of PUBLISH messages and CONNECT messages. This property holds a UTF-8-encoded string that describes the contents of a testamentary or PUBLISH message.

It is determined by the application that sends and receives messages. The content type cannot be tampered with during message forwarding.

A typical application of content types is to store MIME types, such as text/plain for text files and audio/aac for audio files.

Tags: Messages attributes payloads messages wills types valid UTF-8 content identification meaning data characters bytes encoding files standards applications two typical Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Shulou Information Apple macOS vpn