Data communication method based on MQTT and Websocket

A data communication and data technology, applied in the field of data transmission, can solve the problem of time-consuming and high cost of broker locating message queues, achieve real-time communication of server resources and bandwidth, reduce the number of topics, and solve stability problems

Pending Publication Date: 2022-08-05
GUANGDONG MEIWEIXIAN FLAVORING & FOOD
View PDF0 Cites 0 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0009] In addition, since there are usually many types of data collected by smart terminal devices, there may be many topics that need to be set for MQTT, and too many topics will make the MQTT proxy server immediately figure 1 The broker needs to open up more s

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Data communication method based on MQTT and Websocket
  • Data communication method based on MQTT and Websocket
  • Data communication method based on MQTT and Websocket

Examples

Experimental program
Comparison scheme
Effect test

Example Embodiment

[0036] Example 1

[0037] A data communication method based on MQTT and Websocket, comprising the following steps:

[0038] S1. The intelligent terminal device publishes an MQTT message with topic information.

[0039] The MQTT message follows the following data transmission protocol (a customization of the payload part of the MQTT message), such as Figure 4 , 5 As shown, including SOF, Length, Data, CRC16 and EOF; where SOF and EOF are used as the frame header and frame end respectively, Length is used to set the length of Data, CRC16 is used to verify the integrity of the data frame; the Data part also includes msg , time, index, value and other custom fields, where the msg field is used to indicate the data type, the time field is used to indicate the release time, the index field is used to indicate the device number, the value field is used to indicate the data value, and the custom field is used to indicate the data value. To support users to expand according to the ...

Example Embodiment

[0050] Embodiment 2

[0051] In order to further solve the stability problem of data transmission in high concurrency scenarios, the server in the second embodiment adopts a Kafka proxy cluster, which is usually composed of more than two background servers. On this basis, the second embodiment further proposes a A data communication method based on MQTT, Kafka and Websocket, the main difference from Embodiment 1 is that it has carried out the following improvements to step S4:

[0052] The background server uses the partition mechanism of Kafka to receive the corresponding MQTT messages, and writes them to the disk in a sequential manner. Since Kafka is also based on the publish / subscribe model, it can directly create Kafka based on the topic of the received MQTT message. The message queue and the MQTT message are stored in it. The messages in each Kafka message queue are processed by the service corresponding to the topic. According to the topic to which the data type s...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

PUM

No PUM Login to view more

Abstract

The invention discloses a data communication method based on MQTT and Websocket, and the method comprises the steps: S1, an intelligent terminal device issues an MQTT message, and the MQTT message carries Topic information and also carries data type information subordinate to the Topic information; s2, receiving the MQTT messages by the MQTT message proxy server, and respectively creating message queues for storage according to different Topic of the MQTT messages; s3, the background server subscribes the corresponding Topic to the MQTT message proxy server according to the own demand; and S4, after receiving the corresponding MQTT message, the background server sends the information corresponding to the corresponding data type under the corresponding Topic to the client which establishes long connection with the background server through the Websocket protocol according to the subscription condition of the client for the data type. The invention provides a reliable and timely data communication method for the service scene of intelligent terminal equipment-server-client, and can also reduce the number of Topic in the MQTT message proxy server, thereby reducing the occupation of the disk space of the MQTT message proxy server and improving the message consumption rate in the MQTT message proxy server.

Description

technical field [0001] The invention relates to a data transmission method, in particular to a data communication method based on MQTT and Websocket. Background technique [0002] With the rapid development of Internet technology, the popularization of intelligent terminal equipment, and the diversification of business requirements, the importance of data communication between terminal equipment has become increasingly prominent, especially now such as "smart terminal equipment-server-client" There are more and more applications in business scenarios. How to ensure the real-time data acquisition and the reliability of data transmission in practical applications is the key to be considered in the data communication process. [0003] MQTT is a "lightweight" communication protocol based on the publish / subscribe model, which is built on the TCP / IP protocol. The biggest advantage of MQTT is that it can provide real-time and reliable message services for connected remote devices ...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

Application Information

Patent Timeline
no application Login to view more
IPC IPC(8): H04L67/02H04L67/1004H04L67/1097H04L67/14H04L67/566H04L67/568H04L9/40
CPCH04L67/02H04L67/1004H04L67/1097H04L67/14H04L63/123
Inventor 李翠旭李建符姜燕刘占傅梓渊梁展飞扈圆舒罗庆徐婷林虹
Owner GUANGDONG MEIWEIXIAN FLAVORING & FOOD
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products