Haixin: An MQTT protocol for the Internet of Things

Source: Internet
Author: User
Tags mqtt broker

What is the MQTT protocol

MQTT (Message Queuing Telemetry transport protocol) is a lightweight two-way message Transfer protocol developed by IBM in 1999 for applications such as the Internet of Things (IoT), primarily to address the problem of communication between devices used on the IoT and communication between these devices and back-end application systems.

Why an MQTT (or similar) protocol is required

With the rapid development of smart hardware and mobile internet technology, traditional Internet Protocol is becoming more and more difficult to meet the needs of IoT, which is embodied in: mobile network is expensive, low bandwidth, poor reliability, running in embedded device, processor and memory resources are limited; massive online devices generate huge data, Brings a lot of network overhead and processing pressure to the cloud.

How MQTT Works

MQTT includes the client, agent (broker) two parts, to the smart home system, for example, the end of smart appliances and mobile phones for the client, the Cloud Center as a proxy. The client first initiates a request to the agent, after the agent receives the client authentication, after the authentication passes between the client and the agent establishes a TCP long connection channel, the client through this channel subscribes to several subjects of interest (TOPIC), while in its own state changes, publishes the message to the corresponding topic, The agent sends the message to all clients that are subscribing to the topic, such as. Unlike HTTP, Mqtt is a multi-to-many communication protocol that is not directly connected to a device, but communicates with one another through an agent. It is a natural asynchronous protocol that can be used to decouple the requester-side from the response.

What are the benefits of the MQTT protocol?

Mqtt optimizes the design of IoT scenarios, taking into account the accessibility of the network, the connectivity of messages, and energy consumption. Specifically:

One is that it is particularly lightweight, using a 8-bit system, 30K of space, to run MQTT clients.

The second is that it is designed for unstable networks, and the transport protocols in general are based on stable networks, which are optimized for this stable network. Mqtt on the contrary, the protocol more consider the uncertainty of the network, which itself is very streamlined, the smallest transmission byte only two, so that in the more severe network conditions still have a better message to reach the rate.

Thirdly, the interaction pattern of its message is not the same as in the traditional sense, it adopts the mode of publish and subscribe. When a data source publishes a message, multiple subscribers can receive the message at the same time, which is more flexible for IoT scenarios where many devices are interconnected.

There's a message. The quality of Service (QoS) mechanism allows the user to select "at most once", "at least once" or "once only" transmission quality according to the needs of the application, and weigh the tradeoff between efficiency and quality.

Five is the notification mechanism (last-will-and-testament) of the client exception interrupt. When a device is not connected, the server side has a special mechanism to immediately know what the situation of the device, so that can be very fast feedback, a certain node to make some compensation.

What successful practices have been achieved with MQTT

  1. Internet of Things Cloud

Evothings: A foreign IoT ecosystem platform that provides a full suite of hardware and software development tools to help developers build smart hardware prototypes and develop message push services.

Yeelink: One of the largest IoT cloud platforms in the country, providing sensor cloud services to users and intelligent hardware developers, and enabling reliable condition monitoring through real-time data processing.

  2. Real-time message push

Facebook is an early internet giant with an MQTT protocol that uses MQTT in mobile clients to update notifications, messages, bookmarks, and more.

Cloud Bar and other platforms with the MQTT protocol to provide real-time messaging services, real-time push messages to any device, fast to millions of users to send messages, to achieve a single device to push, real-time display of online users, usage. Currently in the tens of thousands of developers, billions of terminals to provide push services. Domestic Sohu and other enterprises also use MQTT as the Android mobile phone client and server-side push message protocol.

What's the problem with MQTT?

  1. Poor performance in 2G/3G network environments where network changes are frequent or less stable.

After each TCP disconnection or disconnect, the client immediately initiates TCP reconnection, sends the Connect command in turn after the connection succeeds, subscribes to the subscrible command, and, when the network is switched frequently or is less stable, the above mechanism increases the already unbearable weak network burden to a certain extent. Some reference resources indicate that adjustments to the business dimension of the re-connect policy, wait timeout, and so on can optimize the problem. In addition, other UDP-based IoT protocols such as COAP are better adapted for this type of network.

  2. Mqtt cannot be applied for a terminal environment that does not have TCP/IP support.

Can be supplemented with the MQTT-SN (MQTT for sensor Networks) protocol, which is designed for very limited-like sensors to send UDP packets based on wireless LANs such as IEEE 802.15.4, and through MQTT-SN gateways and MQTT Broker to establish a connection. The process architecture is broadly as follows:

MQTT Referral Resources

Mosca: A better-functioning broker based on the NODEJS implementation

MQTT client Libraries for paho:c/c++, Python, Java and other languages

Mosquitto: A fully functional open source native broker

Copyright Notice: Original source: http://mt.sohu.com/20160310/n439960879.shtml?qq-pf-to= PCQQ.C2C, Haixin, thanks to the original author's hard work, such as reproduced related to copyright and other issues, please contact us (Public number: Number of unobstructed, QQ Group: 299719834) will be processed in the first time, thank you!

Haixin: An MQTT protocol for the Internet of Things

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.