— Blogs —
—Products—
WhatsApp:+8615367865107
Address:Room 102, District D, Houhu Industrial Park, Yuelu District, Changsha City, Hunan Province, China
Product knowledge
Time:2021-12-06 21:31:48 Popularity:761
HTTP and MQTT protocol Features and scope of application
REST/HTTP (Loosely Coupled Service Call)
REST (Representational State Transfer), representing state transfer, is a communication style developed based on the HTTP protocol, which is currently not a standard.
REST/HTTP scope of application:
REST/HTTP is mainly to simplify the system architecture in the Internet, quickly realize the loose coupling of the interaction between the client and the server, and reduce the interaction delay between the client and the server.
Therefore, it is suitable for the application level of the Internet of Things to open up the resources in the Internet of Things through REST, and realize that the service can be called by other applications.
REST/HTTP features:
1. REST refers to a set of architectural constraints and principles.
An application or design that meets these constraints and principles is RESTful.
2. The interaction between the client and the server is stateless between requests.
3. On the server side, application status and functions can be divided into various resources, which are exposed to the client.
Examples of resources are: application objects, database records, algorithms, etc.
Each resource uses URI (Universal Resource Identifier) to get a unique address.
All resources share a unified interface to transfer state between the client and the server.
4. Standard HTTP methods are used, such as GET, PUT, POST and DELETE.
REST/HTTP reviews:
REST/HTTP is actually the encapsulation style of service calling API in the Internet. Data collected in the Internet of Things is collected in the Internet of Things application system. In the Internet of Things application system, the data service can be opened up by opening the REST API. Called by the application.
MQTT protocol (low bandwidth)
MQTT (Message Queuing Telemetry Transport), Message Queuing Telemetry Transport, an instant messaging protocol developed by IBM, is more suitable for IoT scenarios.
The MQTT protocol uses a publish/subscribe model. All IoT terminals are connected to the cloud through TCP. The cloud manages the communication content of each device's attention through themes, and is responsible for forwarding messages between devices.
MQTT considers the difference in computing performance of different devices when designing the protocol, so all protocols use binary format encoding and decoding, and the encoding and decoding formats are very easy to develop and implement.
The smallest data packet is only 2 bytes, which is also very adaptable to low-power and low-speed networks.
There is a very complete QOS mechanism, and three message delivery modes can be selected at most once, at least once, and exactly once according to the business scenario.
It runs on top of the TCP protocol and supports the TLS (TCP+SSL) protocol, and since all data communication passes through the cloud, security is better guaranteed.
Scope of application: Provide data transmission and monitoring of remote devices based on cloud platforms under low-bandwidth and unreliable networks.
Features of MQTT protocol:
1. Use agent-based publish/subscribe message mode to provide one-to-many message publishing.
2. Use TCP/IP to provide network connection.
3. Small-scale transmission, low overhead (fixed-length header is 2 bytes), and protocol exchange is minimized to reduce network traffic.
4. Support QoS, there are three kinds of message publishing service quality: "At most once", "At least once", and "Only once".
The main implementation and application of the protocol:
1. There are protocol frameworks in multiple language versions such as PHP, JAVA, Python, C, and C#.
2. An important part of IBM Bluemix is its IoT Foundation service, which is a cloud-based MQTT instance.
3. Mobile applications have also started to use MQTT for a long time, such as Facebook Messenger and com.
Comments:
The MQTT protocol is generally suitable for device data collection to the end (Device-"Server, Device-"Gateway), centralized star network architecture (hub-and-spoke), not suitable for communication between devices, and device control capabilities are weak. The real-time performance is poor, generally at the second level.
The above are the characteristics and scope of application of the HTTP protocol and the MQTT protocol.
Related recommendations
Related products
Screenshot, WhatsApp to identify the QR code
WhatsApp number:+8615367865107
(Click on WhatsApp to copy and add friends)