CN111741129A - MQTT protocol communication method and system for realizing multiplexing - Google Patents

MQTT protocol communication method and system for realizing multiplexing Download PDF

Info

Publication number
CN111741129A
CN111741129A CN202010754458.1A CN202010754458A CN111741129A CN 111741129 A CN111741129 A CN 111741129A CN 202010754458 A CN202010754458 A CN 202010754458A CN 111741129 A CN111741129 A CN 111741129A
Authority
CN
China
Prior art keywords
mqtt
client
tcp channel
proxy server
tcp
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010754458.1A
Other languages
Chinese (zh)
Inventor
王顺
刘爽
闵济海
叶增军
姜红杉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nanjing Tetra Electronic Technology Co ltd
Original Assignee
Nanjing Tetra Electronic Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nanjing Tetra Electronic Technology Co ltd filed Critical Nanjing Tetra Electronic Technology Co ltd
Priority to CN202010754458.1A priority Critical patent/CN111741129A/en
Publication of CN111741129A publication Critical patent/CN111741129A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/54Presence management, e.g. monitoring or registration for receipt of user log-on information, or the connection status of the users
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/562Brokering proxy services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/26Special purpose or proprietary protocols or architectures

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computing Systems (AREA)
  • Computer Security & Cryptography (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention discloses a method and a system for realizing multiplexing MQTT protocol communication, wherein a plurality of TCP channels are established, when an MQTT client logs in a proxy server, a mapping table of a login client and the TCP channels is obtained, when a message is received and sent, the TCP channel corresponding to the MQTT client is further searched in the mapping table through an ID of the MQTT client, then all message contents of the TCP channel are obtained, and finally multiplexing of the TCP channels is realized. The invention solves the problem that a star network topology structure such as Lora and Zigbee communication is accessed to the Internet of things protocol, so that the MQTT proxy server is compatible with the existing MQTT protocol at the same time, and the equipment supporting the standard MQTT protocol can be normally accessed.

Description

MQTT protocol communication method and system for realizing multiplexing
Technical Field
The invention belongs to the network communication technology, and particularly relates to a method and a system for realizing multi-path MQTT protocol communication.
Background
MQTT (message queue telemetry transport) is a publish/subscribe paradigm based messaging protocol under the ISO standard (ISO/IEC PRF 20922). It works on the TCP/IP suite and is a publish/subscribe messaging protocol designed for remote devices with poor hardware performance and in poor network conditions.
For the current MQTT protocol, the MQTT channels and the TCP channels are in one-to-one correspondence, so that the MQTT protocol and a transmission layer are coupled together, and the method has the advantages of low protocol overhead, tolerance to an unstable network, fault recovery and support of large concurrent connection.
However, as shown in fig. 1, in the prior art, MQTT clients correspond to TCP channels one to one, the TCP channels cannot be multiplexed, and the current MQTT protocol is coupled as an upper layer protocol and a transport layer, and does not support a star-type network topology or transport layer multiplexing, which has limitations.
Disclosure of Invention
The purpose of the invention is as follows: the invention aims to solve the defects in the prior art and provides a method and a system for realizing multiplexing MQTT protocol communication.
The technical scheme is as follows: the invention discloses a method for realizing multi-path multiplexing MQTT protocol communication, which comprises the following steps:
step 1, establishing a plurality of TCP channels (the MQTT client establishes the TCP channels through a gateway and an MQTT proxy server) on a transmission layer, and performing communication connection on the same group of MQTT clients and the MQTT proxy server through the same TCP channel, namely: making a one-to-many mapping relation between a plurality of MQTT clients in the same group and a TCP channel; the one-to-many mapping relation is dynamically generated according to login (online) and offline of the MQTT client;
step 2, logging in an MQTT proxy server at the MQTT client, and acquiring a mapping relation between the MQTT client and a TCP channel by the MQTT proxy server;
and 3, during work, when the MQTT proxy server needs to forward the message, firstly, the MQTT client-TCP channel mapping relation table is inquired and detected through the ID of the MQTT client, if the corresponding TCP channel is found and the corresponding MQTT client is determined, the MQTT proxy server then forwards the message, otherwise, the message is discarded.
Further, in step 3, when the one-to-many mapping relationship table between the MQTT client and the TCP channel is queried and detected, whether the TCP channel is online or not and whether the MQTT client is online or not are respectively and independently determined.
Judging whether the TCP channel is on line or not according to whether the TCP channel receives and transmits message data or not; if the TCP channel does not receive and transmit message data, judging that the TCP channel is offline, judging that a plurality of MQTT client sides connected with the TCP channel are also offline, and then discarding the message data; if the TCP channel can receive and transmit message data, judging that the TCP channel is on-line;
and judging whether the MQTT client side is on-line or not according to whether the MQTT proxy server receives the MQTT heartbeat frame sent by the MQTT client side or not, if the MQTT proxy server can receive the MQTT heartbeat frame sent by a certain MQTT client side, judging that the MQTT client side is on-line, and if not, judging that the MQTT client side is off-line and discarding message data.
The other end of the MQTT proxy server communicates with a standard MQTT client through a TCP channel.
The invention also discloses a system for executing the MQTT protocol communication method for realizing multiplexing, which comprises an MQTT proxy server, a standard MQTT client and a plurality of groups of MQTT clients; the MQTT proxy server in the transmission layer is connected with different groups of MQTT clients through corresponding TCP channels to establish a plurality of TCP connection requests, and when the MQTT client logs in the MQTT proxy server through the MQTT client, a one-to-many mapping relation between the MQTT client and the TCP channels is obtained by searching through an ID of the MQTT client; when receiving and sending messages, independently judging whether a TCP channel is on-line or not and whether an MQTT client is on-line or not; finally, the MQTT proxy server realizes multiplexing; the other end of the MQTT proxy server communicates with a standard MQTT client through a TCP channel.
The invention also discloses a computer readable storage medium, which stores a computer program, and the computer program can realize the MQTT protocol communication method for realizing multiplexing when the computer executes the computer program.
Has the advantages that: the invention can realize multiplexing, and further solve the problem that a star network topology structure such as Lora and Zigbee communication is accessed to an Internet of things protocol; meanwhile, the method can be compatible with the existing MQTT protocol, and ensures that the equipment supporting the standard MQTT protocol can be normally accessed.
Drawings
FIG. 1 is a general framework diagram of a prior art MQTT proxy server;
FIG. 2 is a schematic diagram of an overall system framework according to an embodiment.
Detailed Description
The technical solution of the present invention is described in detail below, but the scope of the present invention is not limited to the embodiments.
As shown in fig. 2, the MQTT protocol communication method for implementing multiplexing of this embodiment includes the following specific steps:
step 1, establishing a plurality of TCP channels on a transmission layer, and performing communication connection between the same group of MQTT clients and an MQTT proxy server through the same TCP channel, namely: making a one-to-many mapping relation between a plurality of MQTT clients in the same group and a TCP channel; the one-to-many mapping relation is dynamically generated according to login (online) and offline of the MQTT client;
step 2, logging in an MQTT proxy server at an MQTT client, and acquiring a mapping relation between the MQTT client and a TCP channel;
and 3, during work, when the MQTT proxy server needs to forward the message, firstly, the MQTT client-TCP channel mapping relation table is inquired and detected through the ID of the MQTT client, if the corresponding TCP channel is found and the corresponding MQTT client is determined, the MQTT proxy server then forwards the message, otherwise, the message is discarded.
When a one-to-many mapping relation table between the MQTT client and the TCP channel is inquired and detected, whether the TCP channel is on line and whether the MQTT client is on line are respectively and independently judged.
Judging whether the TCP channel is on line or not according to whether the TCP channel receives and transmits message data or not; if the TCP channel does not receive and transmit message data, judging that the TCP channel is offline, judging that a plurality of MQTT client sides connected with the TCP channel are also offline, and then discarding the message data; if the TCP channel can receive and transmit message data, judging that the TCP channel is on-line;
and judging whether the MQTT client side is on-line or not according to whether the MQTT proxy server receives the MQTT heartbeat frame sent by the MQTT client side or not, if the MQTT proxy server can receive the MQTT heartbeat frame sent by a certain MQTT client side, judging that the MQTT client side is on-line, and if not, judging that the MQTT client side is off-line and discarding message data.
The other end of the MQTT proxy server communicates with a standard MQTT client through a TCP channel.
In this embodiment, the MQTT client and the TCP channel are made into a one-to-many mapping table as shown in table 1,
TABLE 1
Figure DEST_PATH_IMAGE001
Table 1 shows a corresponding relationship between an ID of an MQTT client and an ID of a TCP transmission channel according to the present invention, and the mapping relationship between the MQTT client and the TCP channel can be queried and detected through the ID of the MQTT client.
Namely: the method comprises the steps of firstly identifying the ID of the MQTT client needing to forward the message, then searching the ID of the corresponding TCP channel in the mapping relation according to the ID of the MQTT client, further obtaining the TCP channel for data transmission, and ensuring the orderliness and high efficiency in the message forwarding process. The MQTT client and the TCP channel are mapped in a one-to-many mode, so that the coupling between the MQTT protocol and the TCP protocol is relieved.
The system for implementing the multi-path multiplexing MQTT protocol communication method comprises an MQTT proxy server, a standard MQTT client and a plurality of groups of MQTT clients; the MQTT proxy server in the transmission layer is connected with different groups of MQTT clients through corresponding TCP channels to establish a plurality of TCP connection requests, and when the MQTT client logs in the MQTT proxy server through the MQTT client, a one-to-many mapping relation between the MQTT client and the TCP channels is obtained by searching through an ID of the MQTT client; when receiving and sending messages, independently judging whether a TCP channel is on-line or not and whether an MQTT client is on-line or not; finally, the MQTT proxy server realizes multiplexing; the other end of the MQTT proxy server communicates with a standard MQTT client through a TCP channel.
A computer-readable storage medium of an embodiment stores a computer program that causes a computer to implement the above-described MQTT protocol communication method that implements multiplexing when executed.

Claims (7)

1. A MQTT protocol communication method for realizing multiplexing is characterized in that: the method comprises the following specific steps:
step 1, establishing a plurality of TCP channels on a transmission layer, wherein the same group of MQTT clients share the same TCP channel to be in communication connection with an MQTT proxy server, namely: forming a one-to-many mapping relation by a plurality of MQTT clients in the same group and a TCP channel, wherein the one-to-many mapping relation is dynamically generated according to the login and the offline of the MQTT clients;
step 2, logging in an MQTT proxy server at the MQTT client through a TCP channel, and acquiring a mapping relation between the MQTT client and the TCP channel by the MQTT proxy server and recording the mapping relation into an MQTT client-TCP channel mapping relation table;
and 3, during work, when the MQTT proxy server needs to forward the message, firstly, the MQTT client-TCP channel mapping table is inquired and detected through the MQTT client ID, if the corresponding TCP channel is found and the corresponding MQTT client is determined, the MQTT proxy server then forwards the message, otherwise, the message forwarded to the MQTT client is discarded.
2. The MQTT protocol communication method for implementing multiplexing of claim 1, wherein: and in the step 3, when the one-to-many mapping relation table between the MQTT client and the TCP channel is inquired and detected, whether the TCP channel is on line and whether the MQTT client is on line are respectively and independently judged.
3. The MQTT protocol communication method for implementing multiplexing of claim 1, wherein: in the step 3, whether the TCP channel is on-line or not is judged according to whether the TCP channel receives and transmits message data or not; if the TCP channel does not receive and transmit message data, judging that the TCP channel is offline, judging that a plurality of MQTT client sides connected with the TCP channel are also offline, and then discarding the message data; if the TCP channel can receive and transmit message data, the TCP channel is judged to be on line, and the online state of the MQTT client associated with the TCP channel is kept unchanged.
4. The MQTT protocol communication method for implementing multiplexing of claim 1, wherein: in the step 3, whether the MQTT client is judged on line or not is judged according to whether the MQTT proxy server receives an MQTT heartbeat frame sent by the MQTT client, if the MQTT proxy server can receive the MQTT heartbeat frame sent by a certain MQTT client, the MQTT client is judged on line, otherwise, the MQTT client is judged off line, and message data is discarded.
5. The MQTT protocol communication method for implementing multiplexing of claim 1, wherein: and the other end of the MQTT proxy server is communicated with a standard MQTT client through a TCP channel.
6. A system for implementing the multiplexed MQTT protocol communication method according to any one of claims 1 to 5, wherein: the system comprises an MQTT proxy server, a standard MQTT client and a plurality of groups of MQTT clients; the MQTT proxy server in the transmission layer is connected with different groups of MQTT clients through corresponding TCP channels to establish a plurality of TCP connection requests, and when the MQTT client logs in the MQTT proxy server through the MQTT client, a one-to-many mapping relation between the MQTT client and the TCP channels is obtained by searching through an ID of the MQTT client; when receiving and sending messages, independently judging whether a TCP channel is on-line or not and whether an MQTT client is on-line or not; finally, the MQTT proxy server realizes multiplexing; the other end of the MQTT proxy server communicates with a standard MQTT client through a TCP channel.
7. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program, which makes a computer implement the MQTT protocol communication method for implementing multiplexing according to any one of claims 1 to 5 when the computer executes the computer program.
CN202010754458.1A 2020-07-31 2020-07-31 MQTT protocol communication method and system for realizing multiplexing Pending CN111741129A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010754458.1A CN111741129A (en) 2020-07-31 2020-07-31 MQTT protocol communication method and system for realizing multiplexing

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010754458.1A CN111741129A (en) 2020-07-31 2020-07-31 MQTT protocol communication method and system for realizing multiplexing

Publications (1)

Publication Number Publication Date
CN111741129A true CN111741129A (en) 2020-10-02

Family

ID=72656613

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010754458.1A Pending CN111741129A (en) 2020-07-31 2020-07-31 MQTT protocol communication method and system for realizing multiplexing

Country Status (1)

Country Link
CN (1) CN111741129A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112995302A (en) * 2021-02-07 2021-06-18 深圳市桑达无线通讯技术有限公司 Remote terminal management method based on MQTT transmission protocol
CN114500070A (en) * 2022-02-10 2022-05-13 上海蓝长自动化科技有限公司 MQTT protocol secure communication method based on secret sharing algorithm
CN114520836A (en) * 2022-01-12 2022-05-20 深圳市微创云启科技有限公司 Network communication protocol method and system capable of multiplexing and preventing data tampering
CN114945034A (en) * 2022-05-17 2022-08-26 西北工业大学 Open Internet of things platform based on local area network and ZigBee

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150271299A1 (en) * 2014-03-21 2015-09-24 Ptc Inc. System and method of abstracting communication protocol using self-describing messages
CN105376589A (en) * 2015-10-27 2016-03-02 上海斐讯数据通信技术有限公司 Intelligent TV message push device and method based on MQTT
CN106713124A (en) * 2017-01-24 2017-05-24 深圳市启仑智能科技有限公司 Message push method and system based on MQTT and MYSQL

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150271299A1 (en) * 2014-03-21 2015-09-24 Ptc Inc. System and method of abstracting communication protocol using self-describing messages
CN105376589A (en) * 2015-10-27 2016-03-02 上海斐讯数据通信技术有限公司 Intelligent TV message push device and method based on MQTT
CN106713124A (en) * 2017-01-24 2017-05-24 深圳市启仑智能科技有限公司 Message push method and system based on MQTT and MYSQL

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112995302A (en) * 2021-02-07 2021-06-18 深圳市桑达无线通讯技术有限公司 Remote terminal management method based on MQTT transmission protocol
CN112995302B (en) * 2021-02-07 2022-06-07 深圳市桑达无线通讯技术有限公司 Remote terminal management method based on MQTT transmission protocol
CN114520836A (en) * 2022-01-12 2022-05-20 深圳市微创云启科技有限公司 Network communication protocol method and system capable of multiplexing and preventing data tampering
CN114520836B (en) * 2022-01-12 2024-04-19 深圳市微创云启科技有限公司 Multiplexing network communication protocol method and system capable of preventing data tampering
CN114500070A (en) * 2022-02-10 2022-05-13 上海蓝长自动化科技有限公司 MQTT protocol secure communication method based on secret sharing algorithm
CN114945034A (en) * 2022-05-17 2022-08-26 西北工业大学 Open Internet of things platform based on local area network and ZigBee

Similar Documents

Publication Publication Date Title
CN111741129A (en) MQTT protocol communication method and system for realizing multiplexing
CN108833487B (en) TCP transmission protocol proxy method
US8473620B2 (en) Interception of a cloud-based communication connection
US20060036747A1 (en) System and method for resource handling of SIP messaging
CN106961426B (en) Communication method and device of intelligent equipment
CN106713084B (en) Multi-gateway system of Internet of things
CN100454905C (en) Method for passing through network address switching
CN109327513B (en) Interaction method, interaction device and computer-readable storage medium
CN111683158B (en) MQTT protocol communication method for realizing synchronous request response
CN107528891B (en) Websocket-based automatic clustering method and system
CA2884683C (en) Split network address translation
CN104301287B (en) Many-to-many session implementation method, network node, server and system
CN113194133A (en) MQTT protocol communication method for mass message transmission of power distribution Internet of things
CN115002023B (en) Link aggregation method, link aggregation device, electronic equipment and storage medium
AT515450B1 (en) Procedure for communication in a satellite network
CN209805866U (en) Conversation maintaining system
CN1487706B (en) Method, system and control process for enterprise to communicate timely
CN112968965B (en) Metadata service method, server and storage medium for NFV network node
CN102332999A (en) Interaction system and interaction method of network management based on shared network address translation (NAT)
CN102868642B (en) The method and apparatus of NVGRE message repeating is realized in ASIC
CN115037785B (en) Instant communication system and method
CN109379443B (en) Method for realizing distributed message queue facing to Internet of things
CN110474781B (en) Method and device for forwarding multicast data
US20090094334A1 (en) Gateway with transparent mail relay
CN102857504B (en) Network optimized approach and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20201002

RJ01 Rejection of invention patent application after publication