Skip to content

MQTT Flow Control – MQTT 5 Essentials Part 12

by Florian Raschbichler
8 min read

Welcome to Part 12 of our MQTT 5 Essentials series. In Part 11, we explored Enhanced Authentication in MQTT 5, outlining its role in bolstering security and trust between IoT devices and brokers through a robust, flexible, and more effective authentication process. As we continue navigating the expansive world of MQTT 5, we evaluate Flow Control.

What is Flow Control in MQTT 5?

Flow Control is a dynamic feature introduced in MQTT 5 designed to regulate message traffic between IoT devices and brokers for efficient and stable communication.

IoT deployments encapsulate a wide range of device types. For instance, an MQTT client embedded in a compact sensor varies significantly from one incorporated in a high-performance backend server regarding processing speed and storage capabilities. Consequently, these MQTT clients demonstrate varying tolerance levels for managing in-flight messages. Here, an in-flight message refers to a PUBLISH command with a Quality of Service level of one or two awaiting acknowledgment.

Similarly, an IoT device might connect to multiple MQTT brokers, each with distinct limitations on managing in-flight messages from an MQTT client. To seamlessly manage such diversified conditions among MQTT clients and brokers, MQTT 5 introduces the Flow Control feature.

How Flow Control Works in MQTT 5?

The Flow Control feature functions through a negotiation between the client and broker to establish in-flight windows during the connection. This process involves setting an optional property known as "Receive Maximum" in the CONNECT packet, indicative of the maximum number of unacknowledged PUBLISH messages the client can accommodate. The broker reciprocates with a similar value for “Receive Maximum” in the CONNACK packet. If the "Receive Maximum" value is not specified, the default value of 65,535 is employed.

How Flow Control Works in MQTT 5?Mechanism of How Flow Control Works in MQTT 5

What are the Advantages of Flow Control in MQTT 5?

Flow Control enhances dynamic message flow adjustment for use cases involving diverse systems and devices, fostering transparency and adaptability when multiple teams or vendors collaborate on a project. No longer is it necessary for all parties to pre-establish in-flight windows. If an MQTT 5 client sends more unacknowledged messages than what the Server Receive Maximum permits, the broker sends DISCONNECT with Reason Code 0x93 (Receive Maximum exceeded). This flexibility allows the client and broker to send fewer in-flight messages than the corresponding Receive Maximum permits.

What to do and What not to do?

  • Implementing “Receive Maximum” remains an optional, yet beneficial choice.

  • Both client and broker can establish their unique in-flight windows during the connection initiation.

  • Flow Control is designed to maintain balanced message processing, preventing the overloading of any participating parties.

  • As a feature, Flow Control aligns seamlessly with MQTT 5’s key objectives - enhancing transparency and fostering increased flexibility.

Concluding Our MQTT 5 Journey

MQTT 5 introduces advanced features like Clean Session Start, Payload Format Indicator, and Topic Aliases to optimize connection and publishing operations. Subscription features like Non-local publishing, Retained Message Control, and Shared Subscriptions have been added to facilitate greater control and efficiency in subscriber relationships.

Furthermore, MQTT5 seeks to adapt to the needs of modern IoT applications and large-scale cloud platforms. It addresses the demand for a protocol that operates efficiently even in remote devices with limited power sources, ensuring effective bandwidth usage and reliability over unstable networks.

Notably, MQTT5 also caters to an impressive array of use cases, ranging from connected cars, manufacturing systems, and logistics to enterprise chat applications and mobile apps. This broad application scope is testament to its flexibility and adaptability, appealing to a variety of industries and settings.

Given these significant enhancements, migrating to MQTT 5 presents several compelling benefits. It offers increased performance in large-scale systems, more efficient device communication, and enhanced control over publishing and subscription processes. Additionally, it’s a more adaptable and resilient solution, capable of addressing the complex demands of contemporary IoT applications and cloud platforms.

MQTT 5 stands as the most feature-rich update to the MQTT protocol, offering considerable advancements in scalability, efficiency, and adaptability. Its advanced features and capabilities make it an appealing choice for IoT applications in various industries, encouraging a shift from the previous versions.

We hope this comprehensive series has been informative, covering the gamut of MQTT 5’s new features.

Sign up for our newsletter to get regular updates. Subscribe to our RSS feed here to stay updated. We encourage you to visit our MQTT Glossary for an in-depth understanding of the essential MQTT terminologies. It will equip you with the necessary vocabulary to grasp the complexities of MQTT and its various versions.

Watch the Video

  • 00:00 - Welcome
  • 00:16 - Flow Control in MQTT5
  • 00:42 - Use Cases on How to Use Flow Control in MQTT5
  • 01:05 - Conclusion
  • 01:20 - End of MQTT 5 Essentials

Florian Raschbichler

Florian serves as the head of the HiveMQ support team with years of first hand experience overcoming challenges in achieving reliable, scalable, and secure IoT messaging for enterprise customers.

  • Contact Florian Raschbichler via e-mail

Related content:

HiveMQ logo
Review HiveMQ on G2