Payload Format Indicator and Content Type - MQTT 5.0 new features

Payload Format Indicators and Content Type are two new properties introduced in MQTT 5.0.

Payload Format Indicator

In all packet types of MQTT 5.0, this property exists only in the will property of PUBLISH packet and CONNECT packet.

Payload Format Indicator occupies only one byte size, and has only two values, 0 (0x00) and 1 (0x01).

In the MQTT CONNECT packet, when the value of the Payload Format Indicator of the will property is 0, it means that the will message is an undetermined byte. When the value of the property is 1, it means that the test message is UTF-8 encoded character data. The data in Will Payload must conform to the definition of standard UTF-8.

In the MQTT PUBLISH packet, when the value of the Payload Format Indicator of the PUBLISH property is 0, it means that the PUBLISH message is an undetermined byte. When the value of the property is 1, it means that the payload of the PUBLISH packet is UTF-8 encoded character data. The data in the Payload of PUBLISH packet must conform to the definition of the standard UTF-8.

Content Type

In all packet types of MQTT 5.0, this property also exists only in the will property of PUBLISH packet and CONNECT packet. This property stores UTF-8 encoded strings that describe the contents of a will message or a 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.

Try EMQX Cloud for Free
A fully managed, cloud-native MQTT service
Get Started →

Related Posts

User Properties - MQTT 5.0 new features

User Properties are the user-defined properties that allow users to add their metadata to MQTT messages to expand more application scenarios.

Shifan Yu 2021-11-25
Reason code and ACK - MQTT 5.0 new features

MQTT v3.1.1 protocol has only 10 return codes. These return codes can represent little meaning, and the same return code value can have different meanings in different messages.

2019-08-29
Enhanced authentication - MQTT 5.0 new features

MQTT 5.0 adds a new feature enhanced authentication, which includes query/response style authentication can implement bi-directional authentication of the client and broker.

Rory Zhang 2020-09-21