The MQTT protocol is the most popular IoT protocol in the world today because of its lightweight and flexibility. It has been widely used in IoV, smart homes, logistics, live chat applications and mobile messaging fields and connected hundreds of millions of devices. There are countless devices are using and accessing the MQTT protocol every second of every day. The MQTT protocol provides a stable and reliable communication foundation for these devices. The large number of accesses to these devices also challenges the MQTT protocol specification. The birth of MQTT 5.0 is to better meet this need.
MQTT(message queue telemetry transmission) was originally invented by IBM in the late 1990s. It was originally used to link sensors on an oil pipeline to satellites, so MQTT was designed from the start for limited devices and low-bandwidth, high-latency or unreliable networks. It uses a publish-subscribe model, decouples the sender and receiver of messages in space and time, and provides a stable and reliable network connection based on TCP/IP, has a very lightweight header for reducing transmission cost, supports reliable messaging. So, we can say that it was born to meet the various needs of the IoT scenario. Four years after the MQTT 3.1.1 has been released and became the OASIS standard, MQTT 5.0 was released, which is a significant improvement and upgrade. It is not only to meet the need of the industry at this stage, but to fully prepare the changes in the development of industry in the future. In March 2019, MQTT 5.0 became the new OASIS standard.
With the rapidly increasing number of devices and ever-increasing requirements, the OASIS MQTT technical committee needs to extract the generic parts from the complex requirements, adds these to the standard specification. Also, need to improve performance and ease of use with as little overhead as possible or without reducing ease of use and without adding unnecessary complexity.
Finally, the OASIS MQTT technical committee provides many new functions and features for MQTT 5.0. MQTT 5.0 became one of the most changed versions of MQTT ever. Here, we will list some relatively important features:
The complete list for new attributes is included in appendix C in the protocol standard, you can access the following URL for more details: http://docs.oasis-open.org/mqtt/mqtt/v5.0/cs02/mqtt-v5.0-cs02.html#AppendixC.
As various MQTT broker manufacturers continue to join the MQTT 5.0 support camp (for example, EMQ has fully supported the MQTT 5.0 protocol in September 2018), the gradual migration of the entire industry ecology to MQTT 5.0 has become the general trend. The MQTT 5.0 will be the first choice of the vast majority of IoT enterprises in the future.
We also want the user to embrace MQTT 5.0 early and enjoy the benefits it brings, which is also the purpose of this article. If you've already interested in MQTT 5.0 but still want to know more, you can try reading the following article. We will introduce you to the key features of MQTT 5.0 in an easy-to-understand way.
In this project, we will implement remote control LED lights via NodeMCU(ESP8266) and MQTT broker, and use the Arduino IDE to program NodeMCU ESP8266.
The message retention function of [EMQ X MQTT Broker](https://emqx.io) is implemented by the `emqx_retainer` plugin, which is enabled by default. By modifying the configuration of the` emqx_retainer` plugin, you can adjust the EMQ X Broker's retention message Location, restrict the number of retained messages and maximum payload length, and adjust the expiration time of retained messages.
When MQTT clients publish messages, you can set the retained message flag, and then the next subscribers can receive the latest retained message when subscribe.