Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MQTT 5.0message release process

2025-02-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Overview

MQTT 5.0protocol makes some upgrades to some QoS messages and the process of message processing. This paper briefly introduces the contents of these upgrades.

QOS message format and processing flow

In the MQTT protocol, messages are divided into three levels, using QoS0, QoS1 and QoS2 respectively. These three different QoS values represent different levels of quality of service. The following is a specific description of each quality of service level:

0: send at most (if the message level is QoS 0, the publisher will only send the message once when it is published, regardless of whether the message is delivered or not)

1: send a message at least once (if the message level is QoS 1, the publisher will send it repeatedly when publishing the message to ensure that the message is sent successfully)

2: the message is sent only once and delivery is guaranteed. If the message level is QoS 2, the publisher publishes the message to ensure that the recipient only receives one message and that the message is not duplicated.

Among the three QoS message levels, QoS 0 is the most resource-saving, while QoS 1 still needs to receive a release confirmation message to stop the duplicate message transmission after publishing the message. QoS 2 message transmission requires more steps, it needs 4 messages to be sent to ensure that the message is delivered in a single time, and it is the most expensive in computing resources and bandwidth of all message types.

The following is a flowchart of processing for three different QoS values:

In MQTT 3.0, the message publishing process for QoS 0 is as follows

QoS 0 message

QoS 1 Messa

If the receiver does not receive the QoS1 message or there is a problem with the received QoS1 message, it will not send the PUBACK acknowledgement message, so the sender will not discard the QoS1 message, it will send it again.

This message, so the QoS1 message is likely to be republished.

QoS 2 Messa

In order to ensure that the message is sent at a single time and can be delivered. First of all, it will publish a PUBLISH message, and then the receiver will not return the confirmation message when the reception is completed. It will store the received message, and then return the PUBREC message to the sender. After receiving the PUBREC message, the sender will replace the stored PUBLISH message with the received PUBREC message, and then send the PUBREL message to the receiver. After receiving the PUBREL message, the receiver discards the previously stored state, by which time the message has arrived at the receiver and can be guaranteed to arrive only once.

MQTT protocol is faced with embedded devices with low computing power. Although the processing flow of QoS2 messages has been slightly optimized in MQTT 5.0protocol, the use of QoS2 message communication is still a very resource-consuming operation, so in general, if the priority of message transmission is not very high, please try not to send QoS2 messages.

MQTT 5.0upgrade

The upgrade of MQTT 5.0on QoS is mainly reflected in a little change when the receiver of QoS2 processes the message.

In MQTT 5.0protocol, the process of publishing QoS2 messages here is slightly different from that of MQTT 3.0. in MQTT 3.0, the receiver can store both messages and Packet ID after receiving the QoS2 message, while the implementer of the protocol is forced to store only Packet Id. This is done to force MQTT protocol developers to reduce the bandwidth loss of QoS2 messages. On the receiver side of the QoS2, in addition to the previously returned PacketId, a PUBREC message identifying the Reason Code is returned.

The latest version 3.0 released by EMQ X already includes support for the MQTT 5.0 protocol. Readers are welcome to try it out.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report