هذه الصفحة غير متوفرة حاليًا بلغتك المحلية. نحن نعمل جاهدين على إضافة المزيد من اللغات. شاكرين تفهمك ودعمك المستمر لنا.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Before You Start

Updated on 2024-12-02 GMT+08:00

Introduction

Message Queuing Telemetry Transport (MQTT) is a lightweight underlying protocol for publish-subscribe communication. It provides ordered, reliable, and bidirectional byte stream transmission and supports device-cloud message transfer. It can provide real-time and reliable messaging services for connecting to remote devices while requiring little code and limited bandwidth. As an instant messaging protocol with low overhead and low bandwidth usage, MQTT is widely used in IoT, small devices, and mobile applications.

Figure 1 MQTT

Data Packets

An MQTT message consists of fixed header, variable header, and payload. IoT Device SDKs are recommended for access.

For details about how to define the fixed header and variable header, see the MQTT V3.1.1. The payload can be defined by applications in UTF-8 format, that is, by the devices and the platform.

  • Fixed header: Each MQTT control packet contains a fixed header, which is used to determine the control packet type. In a PUBLISH message, it is also used to determine the maximum quality of service (QoS), such as link establishment, subscription, and release.
  • Variable header: Some MQTT control packets contain a variable header, which is located between the fixed header and the payload. The contents of the variable header vary according to the packet type. A packet identifier contains a variable header, and is used to distinguish different data packets on the same link.
  • Payload: Some MQTT control packets contain a payload at the end of the packet. For a PUBLISH message, the payload is an application message (defined by users).
NOTE:

For details about MQTT syntax and APIs, see MQTT Version V3.1.1.

Control Packet Types

Common MQTT message types include CONNECT, SUBSCRIBE, PUBLISH, and PINGREQ.

  • CONNECT: A client requests a connection to a server. For details about the parameters in the payload of a CONNECT message, see Device Connection Authentication.
  • SUBSCRIBE: A SUBSCRIBE message includes topic filters and maximum QoS. A session can have multiple SUBSCRIBE messages. For details about subscription to the platform, see Topics.
  • PUBLISH: An application message is transmitted from the client to the server or from the server to the client.
    • The main parameter Topic name in the variable header indicates the release topic of the server or client. For details, see Topics.
    • The payload contains the data reported or commands delivered. It is usually a JSON or string object.
  • PINGREQ: A heartbeat request is sent from the client to the server. It is used to notify the server that the client is still alive and confirm that the network connection is not disconnected. The sending interval is determined by the negotiated Keep Alive value.

Constraints

  • An upstream topic is used by a device to send a request, report data, or return a response to the platform.
  • A downstream topic is a command sent by the platform to a device or a response sent by the platform to a device.
  • After a device is connected to IoTDA, the device needs to subscribe to downstream topics. Otherwise, the device cannot receive commands delivered or responses returned by IoTDA. (IoTDA uses implicit subscription. Devices subscribe to the system topic whose QoS is 0 by default.) The calling of an API on the application side requires the cooperation of the device side. For example, if an application delivers a command, the device needs to subscribe to the downstream topic for command delivery. Otherwise, the device cannot receive commands from the platform, and the APIs for delivering commands will time out.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback