CN114025002A - MQTT information transmission method, system and communication equipment - Google Patents

MQTT information transmission method, system and communication equipment Download PDF

Info

Publication number
CN114025002A
CN114025002A CN202111305221.6A CN202111305221A CN114025002A CN 114025002 A CN114025002 A CN 114025002A CN 202111305221 A CN202111305221 A CN 202111305221A CN 114025002 A CN114025002 A CN 114025002A
Authority
CN
China
Prior art keywords
mqtt
node
message
nodes
client
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
CN202111305221.6A
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.)
Shenzhen Hongdian Technologies Corp
Original Assignee
Shenzhen Hongdian Technologies Corp
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 Shenzhen Hongdian Technologies Corp filed Critical Shenzhen Hongdian Technologies Corp
Priority to CN202111305221.6A priority Critical patent/CN114025002A/en
Publication of CN114025002A publication Critical patent/CN114025002A/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/143Termination or inactivation of sessions, e.g. event-controlled end of session
    • H04L67/145Termination or inactivation of sessions, e.g. event-controlled end of session avoiding end of session, e.g. keep-alive, heartbeats, resumption message or wake-up for inactive or interrupted session
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L51/00User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
    • H04L51/04Real-time or near real-time messaging, e.g. instant messaging [IM]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks

Abstract

The application provides a method, a system and communication equipment based on MQTT information transmission, the method is applied to an information transmission system, the system comprises a plurality of nodes, each node in the plurality of nodes comprises an MQTT client and an MQTT server, the MQTT servers on different nodes are connected with each other, a first message from the first MQTT client is sent to the MQTT servers on other nodes except the first node through the first MQTT server on the first node, and the first node is any one of the plurality of nodes. Moreover, the first MQTT server may also receive a second message sent by the MQTT servers on other nodes except the first node. The method provided by the application realizes that the information of each node in the information transmission system is equivalent, and the stability of the whole system is not influenced no matter which node is disconnected, thereby ensuring that the system service is not influenced by the fault node.

Description

MQTT information transmission method, system and communication equipment
Technical Field
The application belongs to the technical field of MQTT transmission protocols, and particularly relates to a method, a system and communication equipment based on MQTT information transmission.
Background
Along with the increasingly wide application of the wireless self-organizing network, the wireless self-organizing network has important significance for forming a communication network in an area lacking infrastructure, and is particularly suitable for emergency rescue and relief work, emergency action in remote areas and the like. The wireless self-organizing network form breaks through the geographical limitation of the traditional wireless cellular network, can be deployed more quickly, conveniently and efficiently, and is suitable for the communication needs of some emergency occasions, such as individual soldier communication systems in battlefields.
In the related art, the wireless self-organizing network based on the MQTT distributed service framework reduces network transmission delay and improves service response speed and service quality.
However, the conventional MQTT distributed service framework is often designed based on a C/S architecture, one central node serves as a server, other nodes serve as clients to connect for communication and message transmission, and if a node serving as the server is disconnected, the whole message system of the ad hoc network is completely broken down.
Disclosure of Invention
The embodiment of the application provides a method, a system and communication equipment for transmitting information based on MQTT, which can solve the problem that the whole system is paralyzed due to the fact that one node is disconnected, so that terminals in the system are intercommunicated, and the effect of information sharing is achieved.
In a first aspect, a method for transmitting information based on MQTT is provided, where the method is applied to an information transmission system, the system includes multiple nodes, each node in the multiple nodes includes an MQTT client and an MQTT server, and the MQTT servers on different nodes are connected to each other, and the method includes: a first MQTT server on a first node sends a first message from a first MQTT client on the first node to MQTT servers on other nodes except the first node, wherein the first node is any one of a plurality of nodes; and the first MQTT server receives a second message sent by the MQTT servers on other nodes except the first node.
In the method provided by the first aspect, the first message from the first MQTT client is sent to MQTT servers on other nodes except the first node through the first MQTT server on the first node, so that the other nodes except the first node can receive the first message on the first node. Moreover, the first MQTT server may also receive a second message sent by the MQTT servers on other nodes except the first node, so that the first MQTT server may also receive second information on other nodes except the first node. The method realizes that the information of each node is equivalent, and the stability of the whole system is not influenced no matter which node is disconnected, thereby ensuring that the system service is not influenced by the fault node.
Optionally, the first message includes: subscribe to messages, and/or publish messages. In this implementation manner, the first MQTT server on the first node may send a subscription message or a publish message from the first MQTT client to MQTT servers on other nodes except the first node, so that the other nodes except the first node may receive a subscription topic or a sending topic on the first node.
Optionally, when the first message includes a subscription message, the method further includes: the first MQTT server stores the first message from the first MQTT client locally. In this implementation, when the first message sent by the first MQTT client is a subscription message, the subscription message may be locally stored in order to facilitate recording of the subscription message at the first node.
Optionally, the second message includes a subscription message, and the method further includes: and the first MQTT server locally stores the second message. In this implementation manner, when the first MQTT server receives that the second message sent by the MQTT server on the other node except the first node is the subscription message, it indicates that the node notifies the first node of the subscription message on the node, and therefore, in order to keep synchronization of information of each node, the subscription message needs to be stored locally.
Optionally, the second message includes a publish message, and the method further includes: and the first MQTT server side sends the second message to the first MQTT client side. In this implementation manner, when the first MQTT server receives that the second message sent by the MQTT servers on the other nodes except the first node is the publish message, it indicates that the publish message is required by the first MQTT client on the first node, and therefore the first MQTT server sends the publish message to the first MQTT client.
Optionally, the method further includes that the first MQTT server queries a locally stored subscription topic; and when the locally stored subscription theme is matched with the published message, the first MQTT server side sends the published message to the first MQTT client side. In this implementation manner, in order to ensure the accuracy of the published message, the locally stored subscription topic may be searched, and when the locally stored subscription topic is matched with the published topic, the first MQTT server sends the published message to the first MQTT client.
In a second aspect, there is provided an apparatus comprising means for performing the steps of the above first aspect or any possible implementation manner of the first aspect.
In a third aspect, an apparatus is provided that comprises at least one processor and a memory, the at least one processor being configured to perform the method of the first aspect above or any possible implementation manner of the first aspect.
In a fourth aspect, an apparatus is provided that comprises at least one processor configured to perform the method of the first aspect above or any possible implementation manner of the first aspect, and an interface circuit.
In a fifth aspect, there is provided an information transmission system, where the system includes a plurality of nodes, each of the plurality of nodes includes an MQTT client and an MQTT server, and the MQTT servers of different nodes maintain connection, and the system is configured to perform the method in the first aspect or any possible implementation manner of the first aspect.
A sixth aspect provides a communication device comprising an MQTT client and an MQTT server, the communication device being configured to perform the method of the first aspect above or any possible implementation manner of the first aspect.
In a seventh aspect, a computer program product is provided, the computer program product comprising a computer program for performing the method of the first aspect or any possible implementation manner of the first aspect, when the computer program is executed by a processor.
In an eighth aspect, there is provided a computer readable storage medium having stored thereon a computer program for performing the method of the first aspect or any possible implementation manner of the first aspect when the computer program is executed.
In a ninth aspect, there is provided a chip or an integrated circuit, the chip or the integrated circuit comprising: a processor configured to invoke and run the computer program from the memory, so that the device on which the chip or the integrated circuit is installed performs the method of the first aspect or any possible implementation manner of the first aspect.
It is understood that the beneficial effects of the second to ninth aspects can be seen from the description of the first aspect, and are not repeated herein.
Compared with the prior art, the embodiment of the application has the advantages that:
according to the method, the first message from the first MQTT client is sent to the MQTT server on other nodes except the first node through the first MQTT server on the first node, so that the other nodes except the first node can receive the first message on the first node. Moreover, the first MQTT server may also receive a second message sent by the MQTT servers on other nodes except the first node, so that the first MQTT server may also receive second information on other nodes except the first node. The method realizes that the information of each node is equivalent, and the stability of the whole system is not influenced no matter which node is disconnected, thereby ensuring that the system service is not influenced by the fault node.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a schematic diagram of an MQTT information transmission-based system provided by an embodiment of the present application;
FIG. 2 is a schematic diagram of the core components of the MQTT Broker provided by the embodiment of the application;
FIG. 3 is a schematic flowchart of an example of a subscription topic based on an MQTT information transmission method provided by the embodiment of the application;
FIG. 4 is a schematic flowchart of an example of a publishing subject based on an MQTT information transmission method provided by the embodiment of the application;
fig. 5 is a schematic block diagram of a communication device according to an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
First, before describing the methods and systems provided herein, some of the terms that will be referred to immediately below will need to be described. When the present application refers to the terms "first" or "second" etc. ordinal, it should be understood that they are used for distinguishing purposes only, unless they do express an order in accordance with the context.
The terms "exemplary" or "such as" are used herein to mean serving as an example, instance, or illustration. Any embodiment or design described herein as "exemplary" or "e.g.," is not necessarily to be construed as preferred or advantageous over other embodiments or designs. Rather, use of the word "exemplary" or "such as" is intended to present concepts related in a concrete fashion.
Unless otherwise indicated, "/" herein generally indicates that the former and latter associated objects are in an "or" relationship, e.g., a/B may represent a or B. The term "and/or" is merely an associative relationship that describes an associated object, meaning that three relationships may exist, e.g., a and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the present application, "a plurality" means two or more.
The wireless self-organizing network refers to a network combining mobile communication and computer network, which is one kind of mobile computer network, and the user terminal can move freely in the network to maintain communication. Currently, wireless ad hoc networks are focusing more and more on the study of the influence of dynamic network topology on network stability. The mobile change of the nodes of the wireless ad hoc network brings convenience to users and simultaneously causes the change of network topology, and the change of the node positions can cause the instability of network connection due to the characteristics of limited distance of wireless communication, transmission fading and the like. Therefore, the movement of the nodes of the wireless ad hoc network does not only depend on the requirement of optimizing the movement distance of the nodes, but also must consider the stability of the wireless ad hoc network.
MQTT (Message Queuing Telemetry Transport) is a lightweight instant messaging protocol developed by IBM corporation. Unlike the HTTP protocol, the MQTT adopts a publish/subscribe mode instead of the traditional request/response mode, and this lighter mode makes MQTT more suitable for internet-of-things devices with low power consumption and limited network bandwidth. Meanwhile, the MQTT has the characteristics of simplicity, support of continuous call back control, provision of different transmission service qualities, strong customizability and the like, and the value of the MQTT is fully reflected in the current internet of things which is in the state of being in the fire and the heat. The MQTT is used as an important transmission protocol of the Internet of things and supports almost all platforms.
However, in the related art, a distributed service framework based on MQTT is often designed based on a C/S architecture, that is, a central node serves as a server, and other nodes serve as clients to connect, or a middleware transmits messages to ensure the reliability of the messages, and as the service functions processed by the distributed cluster system are gradually enriched, the number of subsystems included in the distributed cluster system is increased, and the calling among the subsystems becomes complicated. When one of the subsystems that are interdependent is modified, all relevant system calls need to be modified.
The message middleware is used for carrying out platform-independent data communication by utilizing an efficient and reliable message transfer mechanism and carrying out integration of the distributed cluster system based on data communication. By providing a messaging and message queuing model, inter-process communication is extended in a distributed environment, such as the more widely used RabbitMQ, ActiveMQ, and the like. In the prior art, a message middleware is usually introduced to decouple mutual invocation among systems, and each subsystem transmits and receives messages through the message middleware to convert direct invocation among systems into asynchronous invocation based on message transmission. However, since the message passing across the nodes may be lost due to a network or the like, there is a possibility that the messages are transmitted and received through the message middleware to be inconsistent with each other. Therefore, how to implement message passing and synchronization across nodes is a problem that needs to be solved at present.
In view of the above, the present application provides a method for MQTT-based information transmission, where each node on multiple nodes in an MQTT-based distributed service framework in the present application is peer-to-peer, that is, each node has an MQTT server and an MQTT client, an MQTT server on a first node is used to send a first message sent by the MQTT client on the first node to an MQTT server on another node, where the first message may be a subscription message or a publish message, the first node refers to any one of the multiple nodes, so as to notify the other nodes of knowing the subscription message or the publish message on the first node, and the MQTT server on the first node is used to receive a second message sent by the MQTT servers on the other nodes, where the second message may be a subscription message or a publish message, so as to notify the first node of knowing the subscription message or the publish message on the other nodes, namely, the information sharing of each node is realized, the information of each node in the whole message sending system is ensured to be consistent, and the disconnection of one node does not influence other nodes in the system.
The following describes, with reference to specific examples, an MQTT information transmission-based system to which the MQTT information transmission-based method provided in the present application is applied.
Fig. 1 is a schematic diagram illustrating an example of a system for transmitting MQTT-based information according to an embodiment of the present application. As shown in fig. 1, the system includes: a plurality of nodes. Each node in the plurality of nodes comprises an MQTT Broker and an MQTT Client, and in order to realize the subscription and the publishing of the messages, the MQTT Broker and the MQTT Client on the same node are connected, and the MQTT Brokers on different nodes are connected with each other. In the example shown in fig. 1, the system takes four nodes as an example, and the nodes can be understood as mobile devices carried by users in the wireless ad hoc network such as: mobile phones, tablets or walkie-talkies, etc. The embodiment of the present application is not limited to the mobile device used in the system.
Optionally, as a possible implementation manner, in order to implement information consistency between nodes, the MQTT brokers on different nodes in the system are connected to each other through a Transmission Control Protocol (TCP), and are kept online through a heartbeat packet, that is, information sharing between the nodes can be implemented.
It should be noted that the heartbeat packet is usually a data packet sent by the server of one node to the server of another node at a short time interval, and informs the server that the server is still online, and the server and the client interact at a short time interval to determine whether the link is valid and transmit some data that may be necessary. Usually, after a socket connection of a TCP is established, it cannot be guaranteed whether the connection is continuously valid, and at this time, the applications on both sides can guarantee that the connection is valid by sending heartbeat packets at regular time. Since it is transmitted at regular intervals, it is called a heartbeat packet, since it is similar to a heartbeat.
However, in general, a long connection is maintained for each node, and the long connection is considered to be valid after a TCP connection is established, and data is continuously transmitted by using the connection without disconnecting the TCP connection.
It should be further noted that, in the embodiment of the present application, in order to enable the service to send a subscription message or a publish message to the local MQTT Broker through the MQTT Client, the MQTT Client and the MQTT Broker on the local node may be connected through the PUB/SUB.
It should be understood that fig. 1 is only an example, and should not limit the application scenario of the embodiment of the present application in any way, for example, in the scenario shown in fig. 1, more electronic devices and the like may also be included. The application is not limited herein.
In the system shown in fig. 1, the MQTT Broker on each node may send a first message to the MQTT Broker on the other nodes. The MQTT Broker on each node may also receive second messages sent by MQTT brokers on other nodes. Therefore, the core components of MQTT Broker on each node can be divided on the basis of fig. 1. Fig. 2 shows a schematic diagram of the core components of MQTT Broker provided in the embodiments of the present application. As shown in fig. 2, the MQTT Broker on each node includes a subscription module, a forwarding module, and a publishing module.
The subscription module is used for receiving subscription service from the MQTT Client; the forwarding module is used for forwarding the subscription theme or the publishing theme to other nodes; the publishing module is used for receiving publishing services from the MQTT Client.
The MQTT information transmission-based system provided by the embodiment of the present application is specifically described above, and a scene used in the present application is described below.
In a possible application scenario, when a fire disaster occurs, firefighters need to share information during the process of fire fighting, and the firefighters need to share information, the method based on MQTT information transmission provided by the application can be used.
In another possible application scenario, when flood disasters occur and emergency rescue and relief workers need to share information, the method based on MQTT information transmission provided by the application can be used.
The method for transmitting messages based on MQTT according to the embodiment of the present application is specifically described below with reference to the schematic diagrams shown in fig. 1 and fig. 2.
Taking the first message as a subscription message and the second message as a subscription message as an example, the method for transmitting the MQTT-based message provided by the embodiment of the present application is specifically described below, and fig. 3 shows a schematic flowchart of a subscription theme of the MQTT-based message transmission method provided by the present application.
As shown in fig. 3, the method includes: s310 to S340.
And S310, initiating a subscription message to the first MQTT Broker according to the service requirement.
After establishing the connection between the first MQTT Broker and the first MQTT Client, the service may initiate a topic subscription to the first MQTT Broker on the first node through the first MQTT Client on the first node according to a requirement.
Note that the first node is any one of a plurality of nodes. The first MQTT Broker is a server on the first node, and the first MQTT Client is a Client on the first node.
And S320, the first MQTT Broker sends the subscription message from the first MQTT Client to MQTT Broker on other nodes except the first node.
In this embodiment of the application, in step S310, when initiating the subscription theme to the first MQTT Broker on the first node through the first MQTT Broker on the first node, the MQTT Broker on the other nodes except the first node also forwards the subscription theme of the MQTT Broker on the corresponding node to the first MQTT Broker through the TCP at the same time, so that when the first MQTT Broker receives the subscription theme, it is first necessary to determine the source of the subscription theme.
When the subscription theme received by the first MQTT Broker is determined to be from the first MQTT Client, it indicates that the Client sends the subscription theme for the first time, and in order to ensure that the theme information subscribed by the Client is also received on other nodes, it is necessary to send the information of the subscription theme of the Client to the MQTT Broker on other nodes in the system. And the first MQTT Broker stores the subscription theme sent by the first MQTT Client.
For example, the first MQTT Broker may store the topic information subscribed on the node locally, or on another server, or may also store the topic information in another easily-obtained place, which is not limited in this embodiment of the application.
S330, the first MQTT Broker stores the theme forwarded and synchronized by the MQTT Broker from other nodes except the first node.
In step S330, in order to make the first node obtain the subscription information on other nodes, when it is determined that the subscription topic received by the first MQTT Broker is from an MQTT Broker on other nodes except the first node to forward a synchronized topic, only the subscription information and the IP information of the MQTT Broker need to be stored.
Similarly, the embodiment of the present application is not limited to this storage, and may be stored locally or on another server.
And S340, returning the ACK of the subscription theme.
In step S340, after the first MQTT Broker saves the subscription message, an Acknowledgement Character (ACK) is returned, that is, the MQTT Broker on the node already receives the subscription topic forwarded and synchronized by the MQTT Broker on other nodes in the system.
The ACK is a transmission control character that the receiving station transmits to the transmitting station in data communication. Indicating that the transmitted data is received without errors.
Illustratively, when the service at node 1 sends a message for subscribing to the topic to the first MQTT Broker through the first MQTT Client. The first MQTT Broker at node 1 receives the message of subscribing to the topic, and node 2, node 3, and node 4 may also send the message of subscribing to the topic corresponding to the node to the first MQTT Broker at node 1. Therefore, when the MQTT Broker at node 1 receives a message subscribing to a topic, it needs to determine whether the message is from the first MQTT Client or from MQTT brokers of other nodes.
When the first MQTT Broker at node 1 receives the message for subscribing to the topic from the first MQTT Client, it indicates that the service at node 1 subscribes to the topic for the first time. At this time, in order to avoid the paralysis of the whole network caused by the disconnection of the node 1, the message of subscribing the topic by the node 1 can be forwarded to MQTT Broker on the node 2, the node 3 and the node 4 respectively. At this time, the node 2, the node 3 and the node 4 receive the message of the topic subscribed by the node 1, and the information on each node is ensured to be consistent. And, MQTT Broker of node 2, node 3 and node 4 may save the event that node 1 subscribes to the topic message, and then node 2, node 3 and node 4 return ACK to the first MQTT Broker on node 1 through the corresponding MQTT Broker, respectively.
When the message for subscribing the theme received by the first MQTT Broker at the node 1 is forwarded from the first MQTT Broker at the node 2, indicating that the theme is subscribed by the first MQTT Client at the node 2, the MQTT Broker at the node 2 forwards the subscription theme to the node 1, the node 3 and the node 4 synchronously. At this time, after receiving the subscription message, the first MQTT Broker at node 1 only needs to save the subscription message locally. Meanwhile, node 1 returns ACK to MQTT Broker of node 2 through the first MQTT Broker.
The above steps S310 to S340 specifically describe how to subscribe to the service topic in the MQTT-based information transmission system. In the following, taking the first message as a publishing message and the second message as a publishing message as an example, how to publish the service theme based on the MQTT message transmission method provided in the embodiment of the present application is specifically described, and fig. 4 shows a schematic flowchart of an example of a publishing theme based on the MQTT message transmission method provided in the present application. As shown in fig. 4, the method includes S410-S430.
S410, the business module issues related topics to the first MQTT Broker according to the needs.
After establishing the connection between the first MQTT Broker and the first MQTT Client, the service may issue a related topic to the first MQTT Broker on the first node through the first MQTT Client on the first node according to a requirement.
Note that the first node is any one of a plurality of nodes. The first MQTT Broker is a server on the first node, and the first MQTT Client is a Client on the first node.
And S420, the first MQTT Broker sends the publishing message from the first MQTTClient to MQTTBrkers on other nodes except the first node.
In this embodiment, after the related topic is published to the first MQTT Broker through the first MQTT Client in step 410, since the MQTT Broker on other nodes also publishes the topic to the first MQTT Broker through TCP at the same time, when the first MQTT Broker receives the published topic, it needs to first determine whether the topic is from the first MQTT Client or from the MQTT Broker of other nodes.
In the embodiment of the application, when it is determined that the publishing topic received by the first MQTT Broker is from the first MQTT Client, a message of the publishing topic of the first MQTT Client needs to be sent to MQTT brokers on other nodes in the system. That is, the first MQTT Broker forwards the received published topic to the MQTT Broker on the node subscribing to the topic, and the MQTT Broker on the node forwards the published topic to the local MQTT Client on the corresponding node.
It should be noted that, sending the message of the theme published by the first MQTT Client to the MQTT Broker on other nodes in the system means sending the message to one node, two nodes or a plurality of nodes except the MQTT Broker.
It should be further noted that the subscription information stored in other nodes may be searched, and the publishing information is sent to the node matched with the subscription information.
And S430, the first MQTT Broker forwards the synchronously forwarded release message from the MQTT Broker on other nodes except the first node to the first MQTT Client.
In step S430, when it is determined that the published topic received by the first MQTT Broker is from a topic synchronously forwarded by MQTT brokers on other nodes in the system, the information only needs to be forwarded to the client subscribing to the topic locally.
And S440, returning the ACK of the subscription theme.
After the step S430 is completed, an ACK for publishing the topic is returned, which indicates that the topic has been published completely. That is, the first MQTT Broker of the node has received the theme from which the MQTT Broker on other nodes in the system forwards synchronization.
Illustratively, when the publishing message received by the first MQTT Broker at node 1 is from the first MQTT Client, it indicates that the topic of service publishing at node 1 needs to be forwarded to other nodes. At this time, the information of the subscription topics stored in other nodes is inquired, and then the published topic is forwarded to the node matched with the subscription topic, that is, when the topic published by the inquiry node 1 is matched with the subscription topic on the node 2, the topic is forwarded to the MQTT Broker on the node 2. At this point, the MQTT Broker on node 2 receives the message that node 1 published the topic. And, the node 2 saves the publish topic message locally, and then the MQTT Broker on the node 2 returns ACK to the first MQTT Broker on the node 1.
When the message for publishing the topic received by the first MQTT Broker at the node 1 is forwarded from the MQTT Broker at the node 2, indicating that the topic is published by the MQTT Client at the node 2, the MQTT Broker at the node 2 synchronously forwards the publishing topic to the node 1, indicating that the publishing message is matched with the subscription message at the node 1, and at this time, after receiving the publishing message, the first MQTT Broker at the node 1 needs to forward the publishing message to the first MQTT Client. Meanwhile, the first MQTT Broker on node 1 returns an ACK to the MQTT Broker on node 2.
In this embodiment of the application, the first MQTT server on the first node sends the first message from the first MQTT client to MQTT servers on other nodes except the first node, so that the other nodes except the first node can receive the first message on the first node. Moreover, the first MQTT server may also receive a second message sent by the MQTT servers on other nodes except the first node, so that the first MQTT server may also receive second information on other nodes except the first node. The method realizes that the information of each node is equivalent, and the stability of the whole system is not influenced no matter which node is disconnected, thereby ensuring that the system service is not influenced by the fault node.
The above describes an embodiment of the method for transmitting information based on MQTT according to the embodiment of the present application with reference to fig. 1 to fig. 4, and the following describes a communication device according to the embodiment of the present application.
A communication device is further provided in the embodiment of the present application, and fig. 5 shows a schematic block diagram of a communication device 500 provided in the embodiment of the present application. As shown in fig. 5, the communication device 500 includes: an MQTT client 510 and an MQTT server 520.
It should be understood that the communication device 500 may be understood as a device of the node in fig. 1.
It should be noted that, for the beneficial effects of the communication device, reference is made to the above description, and details are not described herein.
According to the method, the terminal equipment can be divided into the functional modules. For example, the functions may be divided into functional blocks corresponding to the respective functions, or two or more functions may be integrated into one processing block. The integrated module may be implemented in the form of hardware. It should be noted that the division of the modules in this embodiment is schematic, and is only a logic function division, and there may be another division manner in actual implementation.
It should be noted that, relevant contents of each step related to the above method embodiment may be referred to the functional description of the corresponding functional module, and are not described herein again.
The above embodiments may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, the above-described embodiments may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded or executed on a computer, cause the processes or functions described in accordance with the embodiments of the application to occur, in whole or in part. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains one or more collections of available media. The usable medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium. The semiconductor medium may be a Solid State Drive (SSD).
The embodiment of the present application further provides a computer readable medium for storing a computer program code, where the computer program includes instructions for executing the method based on MQTT information transmission in the embodiment of the present application in the above method. The readable medium may be a read-only memory (ROM) or a Random Access Memory (RAM), which is not limited in this embodiment of the present application.
The present application also provides a computer program product comprising instructions which, when executed, cause the system to perform operations corresponding to the methods described above, respectively.
An embodiment of the present application further provides a system chip, where the system chip includes: a processing unit, which may be, for example, a processor, and a communication unit, which may be, for example, an input/output interface, a pin or a circuit, etc. The processing unit can execute computer instructions to enable the chip to execute any one of the methods for transmitting information based on MQTT provided by the embodiments of the present application.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.

Claims (10)

1. A method based on MQTT information transmission is characterized in that the method is applied to an information transmission system, the system comprises a plurality of nodes, each node in the plurality of nodes comprises an MQTT client and an MQTT server, and the MQTT servers on different nodes are connected with each other, and the method comprises the following steps:
a first MQTT server on a first node sends a first message from a first MQTT client on the first node to MQTT servers on other nodes except the first node, wherein the first node is any one of the plurality of nodes;
and the first MQTT server receives a second message sent by MQTT servers on other nodes except the first node.
2. The method of claim 1, wherein the first message comprises: subscribe to messages, and/or publish messages.
3. The method of claim 2, wherein the first message comprises: subscribing to a message, the method further comprising:
and the first MQTT server side stores the subscription message.
4. The method of claim 2, wherein when the second message comprises: subscribing to a message, the method further comprising:
and the first MQTT server stores the second message.
5. The method of claim 3, wherein when the second message comprises: issuing a message, the method further comprising:
and the first MQTT server side sends the publishing message to the first MQTT client side.
6. The method of claim 5, further comprising:
the first MQTT server side inquires locally stored subscription topics;
and when the locally stored subscription theme is matched with the published message, the first MQTT server side sends the published message to the first MQTT client side.
7. System based on MQTT information transmission, characterized in that it comprises a plurality of nodes, each of which comprises an MQTT client and an MQTT server, the MQTT servers of different nodes being kept connected, the system being adapted to perform the method of claims 1-6.
8. A communication device, characterized in that the communication device comprises an MQTT client and an MQTT server, the communication device being configured to perform the method of claims 1-6.
9. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1 to 6.
10. A chip, comprising: a processor for calling and running a computer program from a memory so that a device on which the chip is installed performs the method of any one of claims 1 to 6.
CN202111305221.6A 2021-11-05 2021-11-05 MQTT information transmission method, system and communication equipment Pending CN114025002A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111305221.6A CN114025002A (en) 2021-11-05 2021-11-05 MQTT information transmission method, system and communication equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111305221.6A CN114025002A (en) 2021-11-05 2021-11-05 MQTT information transmission method, system and communication equipment

Publications (1)

Publication Number Publication Date
CN114025002A true CN114025002A (en) 2022-02-08

Family

ID=80061284

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111305221.6A Pending CN114025002A (en) 2021-11-05 2021-11-05 MQTT information transmission method, system and communication equipment

Country Status (1)

Country Link
CN (1) CN114025002A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114938388A (en) * 2022-07-22 2022-08-23 浙江中控技术股份有限公司 Distributed data transmission method, device, system and storage medium
CN115242805A (en) * 2022-06-11 2022-10-25 北京网聚云联科技有限公司 Gossip-based distributed MQTT message transmission method, transmission system and storage medium
CN116827929A (en) * 2022-03-27 2023-09-29 西安即刻易用网络科技有限公司 Communication system and communication method based on MQTT protocol
CN115242805B (en) * 2022-06-11 2024-04-19 北京网聚云联科技有限公司 Distributed MQTT message transmission method, transmission system and storage medium based on gossip

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111131501A (en) * 2019-12-31 2020-05-08 郑州信大捷安信息技术股份有限公司 MQTT protocol-based message pushing system and method
CN111711663A (en) * 2020-05-26 2020-09-25 北京金山云网络技术有限公司 Processing method and device for publishing and subscribing services and electronic equipment
WO2020211344A1 (en) * 2019-04-17 2020-10-22 平安科技(深圳)有限公司 Mqtt-based message distribution method, server, apparatus, and storage medium
CN113254233A (en) * 2021-06-07 2021-08-13 腾讯科技(深圳)有限公司 Data transmission method, device, equipment and readable storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2020211344A1 (en) * 2019-04-17 2020-10-22 平安科技(深圳)有限公司 Mqtt-based message distribution method, server, apparatus, and storage medium
CN111131501A (en) * 2019-12-31 2020-05-08 郑州信大捷安信息技术股份有限公司 MQTT protocol-based message pushing system and method
CN111711663A (en) * 2020-05-26 2020-09-25 北京金山云网络技术有限公司 Processing method and device for publishing and subscribing services and electronic equipment
CN113254233A (en) * 2021-06-07 2021-08-13 腾讯科技(深圳)有限公司 Data transmission method, device, equipment and readable storage medium

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116827929A (en) * 2022-03-27 2023-09-29 西安即刻易用网络科技有限公司 Communication system and communication method based on MQTT protocol
CN115242805A (en) * 2022-06-11 2022-10-25 北京网聚云联科技有限公司 Gossip-based distributed MQTT message transmission method, transmission system and storage medium
CN115242805B (en) * 2022-06-11 2024-04-19 北京网聚云联科技有限公司 Distributed MQTT message transmission method, transmission system and storage medium based on gossip
CN114938388A (en) * 2022-07-22 2022-08-23 浙江中控技术股份有限公司 Distributed data transmission method, device, system and storage medium
CN114938388B (en) * 2022-07-22 2022-11-11 浙江中控技术股份有限公司 Distributed data transmission method, device, system and storage medium

Similar Documents

Publication Publication Date Title
US9578081B2 (en) System and method for providing an actively invalidated client-side network resource cache
WO2019205907A1 (en) Intelligent device communication platform based on mqtt message protocol
EP1542409A1 (en) Protocol for multi-hop ad-hoc networks
US20120198004A1 (en) System and method for managing multiple queues of non-persistent messages in a networked environment
CN106230896A (en) A kind of information push method, Apparatus and system
CN114025002A (en) MQTT information transmission method, system and communication equipment
CN104811459A (en) Processing method, processing device and system for message services and message service system
CN103475566A (en) Real-time message exchange platform and distributed cluster establishment method
TWI530147B (en) Apparatus and method for level-based self-adjusting peer-to-peer media streaming
CN111885093B (en) Event request transmission method and device, storage medium and electronic equipment
CN102857403B (en) Instant messaging client data sharing method and system
CN102984174A (en) Method and system for reliability guarantee in publish-subscribe system
US10958712B2 (en) Enhanced reliability for information services
JP2004080277A (en) Distributed processing system, substitute node in the same, user side node, and method
WO2023186154A1 (en) Data transmission system and method
CN110474781B (en) Method and device for forwarding multicast data
CN115514698A (en) Protocol calculation method, switch, cross-device link aggregation system and storage medium
Zhai et al. An improved DDS publish/subscribe automatic discovery algorithm
CN113037803A (en) Geological disaster monitoring method and system, electronic equipment and storage medium
CN109905645B (en) Video monitoring equipment directory exchange method and networking platform
CN114827097B (en) Communication network construction method and device and computer equipment
Liang et al. Study on Service Oriented Real-Time Message Middleware
CN114500660B (en) Request processing method, device, equipment and computer readable storage medium
Ivan A web based Publish-Subscribe framework for mobile computing
KR102367017B1 (en) Communication network system and control method thereof

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