Things MQTT-- (the IoT) message push protocol

Brief introduction

The MQTT (the Message Queuing Telemetry Transport, Message Queuing Telemetry Transport Protocol) is a built on TCP / IP protocol "lightweight" message transfer protocol, which is based 发布/订阅(publish/subscribe)mode, released by IBM in 1999. For the code requiring less space or limited network bandwidth remote connections it is very useful, and the device is designed for limited low bandwidth, high latency or unreliable network design.

Based on these advantages, MQTT has become the preferred transport protocol of the Internet of Things smart home, also used by the satellite sensor communication link with the agent, dial-up connection with health care providers, as well as a series of small devices and home automation scenarios. And it is also ideal for mobile applications, because of its small size, low power consumption, minimum packet, and information can be efficiently assigned to one or more receivers.


  • Lightweight, simple, small network overhead, open, and easy to implement
  • Lightweight,
  • Publish / subscribe model, many news release
  • Based on TCP / IP network connection, providing an orderly, non-destructive, two-way connection
  • 1-byte fixed header, 2 bytes of heartbeat messages, minimizing transmission overhead and protocol exchange, effectively reduce network traffic
  • News QoS support, to ensure reliable transmission, there are three news release quality (Qos):
    qos = 0: "at most once", this level will occur missing or duplicate messages, the news release depends on the TCP / IP network
    qos = 1: "at least once "to ensure that the message reaches, but the message is repeated may occur
    qos = 2:" only once "to ensure that the message reaches a
  • Notification mechanism, the two sides will be notified when aborted
  • Supports continuous session control
  • To transfer the amount to a minimum in order to improve the transmission efficiency
  • Allows users to dynamically create a theme, zero maintenance cost


MQTT protocol is widely used in the Internet of Things, mobile Internet, smart hardware, car networking, energy and other fields.

  • Things M2M communication, networking large data acquisition
  • Android push messaging, WEB message push
  • Mobile instant messaging, such as Facebook Messenger
  • Intelligent hardware, furniture intelligent, smart appliances
  • Car networked communications, power station pile collection
  • Smart City, telemedicine, distance education
  • Electricity, oil and energy industry markets

Protocol implementation

MQTT achieve agreement requires the client and server communication is completed, in the communication process, there are three protocols MQTT identity: the publisher (Publish), agent (Broker) (server), subscribers (Subscribe). Among them, news publishers and subscribers are clients, messages proxy server, news release may be subscribers simultaneously.

MQTT transmission message divided into: 主题(Topic)和负载(payload)two parts:

  • Topic, can be understood as the type of message, after subscriber subscription (Subscribe), will receive the message content that topic (payload);
  • payload, can be understood as the content of the message, the subscriber is content specific to be used.

MQTT client

A use application or device MQTT agreement, it is always to establish a network connection to the server. Clients can:

  • Ads Other clients may subscribe;
  • Subscribe to news published by other clients;
  • Unsubscribe or delete the application's message;
  • Disconnected from the server;

MQTT server

MQTT server called "Message Agent" (Broker), may be an application or a device. It is located on the news release and subscribers between, it can:

  • Accept network connections from clients;
  • Customer acceptance of the application of information released;
  • Processing subscribe and unsubscribe request from a client;
  • Forwarding application messages to subscribers of customers;

This article only describes the basic, next will formally introduce how to call MQTT in Qt, and how to connect to the server and other processes.


Published 254 original articles · won praise 484 · views 500 000 +

Guess you like