Processing method, system and device based on MQTT protocol and storage medium
By building a request and response mechanism in the MQTT protocol, the problem of lack of direct request response in the MQTT protocol is solved, and efficient and stable message delivery between the cloud server and the industrial gateway is achieved, which significantly improves the response speed and accuracy, and provides users with the Provides a smooth experience.
Patent Information
- Application Number
- CN202411301204.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-18
- Publication Date
- 2024-12-27
AI Technical Summary
The MQTT protocol lacks a direct request response mechanism, which causes clients to wait and poll responses, reducing system efficiency and response speed.
By building a request and response mechanism in the MQTT protocol, the cloud server publishes request messages to preset topics and subscribes to response topics. The industrial gateway receives request messages and generates response messages, sends them to the cloud server's response topics, and the cloud server verifies response messages and requests. Respond when messages are consistent.
It realizes efficient, stable and reliable messaging between cloud servers and industrial gateways, improves response speed and accuracy, and provides users with a smooth experience and a solid communication foundation.
Smart Images

Figure CN119211381A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of MQTT transmission protocol, and in particular to a processing method, system, device and storage medium based on the MQTT protocol. Background Art
[0002] As a lightweight communication protocol, the MQTT protocol is widely used in the field of transmission protocols. Its core advantage lies in the messaging mechanism based on the publish / subscribe model. In this mechanism, the message publisher publishes data to specific topics, and the clients that subscribe to these topics are able to receive the corresponding messages. However, due to the high complexity of the field of transmission protocol technology, the current MQTT protocol itself does not directly support the client to wait for and receive a specific response to the request after sending a request. The client needs to wait for related messages that may appear on the response topic, which may cause unnecessary waiting time. In addition, since the MQTT protocol does not support blocking waiting for responses, the client may need to constantly poll and check the response topic to get a response, which undoubtedly further reduces the efficiency and response speed of the system.
[0003] Therefore, how to achieve efficient request and response mode, reduce the burden of client processing response matching, and improve the efficiency and response speed of the system has become an important issue that needs to be solved urgently. Summary of the invention
[0004] In view of this, the embodiments of the present application provide a processing method, system, device and storage medium based on the MQTT protocol, which can effectively solve the problems of lack of a direct request response mechanism and low response speed and processing efficiency in the prior art.
[0005] In a first aspect, an embodiment of the present application provides a processing method based on the MQTT protocol, which is applied to a cloud server, including:
[0006] Publish request messages to the preset topic based on the MQTT protocol and subscribe to the response topic;
[0007] Receive a response message returned by the industrial gateway that subscribes to the preset topic;
[0008] The response message and the request message are verified, and the request message is responded to when the response message and the request message are verified to be consistent.
[0009] In some embodiments, publishing a request message to a preset topic based on the MQTT protocol and subscribing to a response topic includes:
[0010] Construct a request message based on the MQTT protocol, and add an ID value in the attribute field of the request message; wherein the ID value is used to uniquely identify the request message;
[0011] The request message with the ID value added in the attribute field is sent to the preset topic, and the response topic of the request message is subscribed; after subscription, the response topic enters a waiting for response state to monitor whether a response message arrives.
[0012] In some embodiments, after sending the request message having the ID value added to the attribute field to the preset topic and subscribing to the response topic of the request message, the method further includes:
[0013] When a response message returned by the industrial gateway is received, a callback thread is entered, and the response message is processed in the callback thread to extract the ID value in the response message.
[0014] In some embodiments, the verifying the response message with the request message, and responding to the request message when the response message and the request message are verified to be consistent includes:
[0015] Verify whether the ID value in the response message is consistent with the ID value in the request message;
[0016] When the ID value in the response message is consistent with the ID value in the request message, the request message is responded to.
[0017] The present application embodiment provides a processing method based on the MQTT protocol, which is applied to an industrial gateway, including:
[0018] Subscribe to the preset topics published by the cloud server;
[0019] Receive a request message published by the cloud server based on the subscribed preset topic;
[0020] A response message is constructed based on the request message, and the response message is sent to the response topic of the cloud server. The response topic is used by the cloud server to verify whether the response message is consistent with the request message, and respond to the request message when the verification is consistent.
[0021] In some embodiments, after receiving the request message published by the cloud server based on the preset topic of subscription, the method further includes:
[0022] Parse the request message to obtain the ID value provided by the cloud server;
[0023] The ID value is used to uniquely identify the request message.
[0024] In some embodiments, the step of constructing a response message according to the request message and sending the response message to a response topic of the cloud server includes:
[0025] Construct a response message, add the ID value to the response message, and send it to the response topic of the cloud server.
[0026] In a second aspect, an embodiment of the present application provides a processing system based on the MQTT protocol, including:
[0027] The cloud server is used to publish request messages to preset topics based on the MQTT protocol and subscribe to response topics;
[0028] The industrial gateway is used to subscribe to the preset topic published by the cloud server, and receive the request message published by the cloud server when the cloud server publishes the request message to the preset topic;
[0029] The industrial gateway is further used to generate a response message based on the request message, and send the response message to the response topic of the cloud server;
[0030] The cloud server is also used to verify the response message and the request message when receiving the response message returned by the industrial gateway; and respond to the request message when the response message is verified to be consistent with the request message.
[0031] In a third aspect, an embodiment of the present application provides a computer device, comprising a processor and a memory, wherein the memory stores a computer program, and the processor is used to execute the computer program to implement the processing method based on the MQTT protocol of the first aspect.
[0032] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, and when the computer program is executed on a processor, the processing method based on the MQTT protocol of the above-mentioned first aspect is implemented.
[0033] The embodiments of the present application have the following beneficial effects:
[0034] The present application discloses a processing method, system, device and storage medium based on the MQTT protocol, which uses the MQTT protocol to build a direct request and response mechanism. The cloud server publishes a request message to a preset topic based on the MQTT protocol and subscribes to the response topic. The industrial gateway subscribes to the preset topic published by the cloud server, receives the request message based on the preset topic, generates a reply message according to the request message, and sends the reply message to the response topic of the cloud server, so that the cloud server verifies the reply message and the request message, and responds to the request message when the verification is consistent. The processing method based on the MQTT protocol of the present application uses the MQTT protocol to build a direct request and response mechanism, which ensures efficient, stable and reliable message transmission between the cloud server and the industrial gateway, guarantees the immediacy of requests and responses, significantly improves the speed and accuracy of responses, brings a smoother experience to users, and provides a solid communication foundation for various application scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0036] Figure 1 An application scenario diagram of a processing method based on the MQTT protocol in an embodiment of the present application is shown;
[0037] Figure 2 A flowchart of a processing method based on the MQTT protocol in an embodiment of the present application is shown;
[0038] Figure 3 Another flow chart of a processing method based on the MQTT protocol in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0039] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.
[0040] The components of the embodiments of the present application generally described and shown in the drawings herein may be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0041] Hereinafter, the terms "including", "having" and their cognates that can be used in various embodiments of the present application are intended only to indicate specific features, numbers, steps, operations, elements, components or a combination of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or a combination of the foregoing items or increasing the possibility of one or more features, numbers, steps, operations, elements, components or a combination of the foregoing items. In addition, the terms "first", "second", "third" and the like are only used to distinguish descriptions and cannot be understood as indicating or implying relative importance.
[0042] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meanings as those generally understood by those skilled in the art to which the various embodiments of the present application belong. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meanings as the contextual meanings in the relevant technical field and will not be interpreted as having idealized meanings or overly formal meanings unless clearly defined in the various embodiments of the present application.
[0043] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0044] Considering the lack of direct request response mechanism in the prior art, and the low response speed and processing efficiency, a processing method based on the MQTT protocol is proposed, which uses the MQTT protocol to build a direct request and response mechanism. Specifically, in this mechanism, the cloud server publishes a request message to a preset topic based on the MQTT protocol and subscribes to the response topic. The industrial gateway subscribes to the preset topic published by the cloud server, receives the request message based on the preset topic, generates a reply message according to the request message, and sends the reply message to the response topic of the cloud server, so that the cloud server verifies the reply message and the request message, and responds to the request message when the verification is consistent. This mechanism ensures efficient, stable and reliable message transmission between the cloud server and the industrial gateway, ensures the immediacy of requests and responses, significantly improves the speed and accuracy of responses, brings a smoother experience to users, and provides a solid communication foundation for various application scenarios.
[0045] The processing method based on the MQTT protocol provided in the embodiment of the present application can be applied in the following aspects: Figure 1 In the application environment, specifically, the processing method based on the MQTT protocol of the present application is applied in a computer system, and the system includes: Figure 1The industrial gateway and cloud server shown in the figure, the industrial gateway is a network device used in the industrial field, the main function is to collect, process and forward data from various industrial equipment (such as sensors, PLCs, machines, etc.), and transmit the data to the cloud server. The cloud server is a server based on cloud computing technology. The cloud server is used to store and process data from the industrial gateway and provide functions such as data analysis, storage, backup and application services. When the industrial gateway communicates with the cloud server through the network, the industrial gateway is responsible for uploading the data from the industrial site to the cloud server, and the cloud server is responsible for processing the data and providing services such as data analysis, storage, and remote access.
[0046] Figure 2 A flow chart of a processing method based on the MQTT protocol of an embodiment of the present application is shown. The processing method based on the MQTT protocol includes the following steps:
[0047] Step S100, the cloud server publishes a request message to a preset topic based on the MQTT protocol, and subscribes to a response topic.
[0048] Exemplarily, the cloud server acts as a publisher. When the cloud server wants to obtain the status information of industrial equipment, it constructs a request message and sends the request message to a preset designated topic so that the industrial equipment that has subscribed to the topic receives the request message. The preset designated topic is a pre-defined topic that is used to identify the type or content of the message so that subscribers can receive corresponding messages according to their interests. At the same time, the cloud server can also subscribe to a response topic to receive the corresponding reply message. The response topic is a pre-defined topic that is used to identify a specific type of response. After the industrial gateway that receives the request message processes the request of the cloud server, it publishes the reply message to the designated topic. The reply message is a response to the request message previously published by the cloud server, and may contain the request result, device status information or other related data.
[0049] In an optional embodiment, if Figure 3 As shown, in step S100, publishing a request message to a preset topic based on the MQTT protocol and subscribing to a response topic include:
[0050] Step S101, construct a request message based on the MQTT protocol, and add an ID value to the attribute field of the request message; wherein the ID value is used to uniquely identify the request message.
[0051] Exemplarily, MQTT (Message Queuing Telemetry Transport) is a lightweight message protocol based on the publish-subscribe model. The present invention utilizes the Property attribute field introduced in MQTT version 5.0. The Property field is a variable-length field containing multiple attributes, which is used to pass additional information in the request message. Attributes may include message size, message expiration time, content type, etc., as well as user-defined attributes (UserProperties).
[0052] That is, when constructing an MQTT message, a random ID value is added to the MQTT message header using the user-defined property (User Property) in the property field. The ID value is unique and is used to uniquely identify the request message and its corresponding response message during message transmission and processing. For example, in a request / response mode, the server can send a request message with a unique ID to the industrial gateway, and the industrial gateway can use the same ID when responding to ensure that the response matches the request correctly. For example, the ID value can be any type of data, usually an integer, string, or other unique value. The ID value can be generated by a UUID generator, a timestamp + serial number, a random number, etc.
[0053] Step S102, sending a request message with an ID value added to the attribute field to a preset topic, and subscribing to the response topic of the request message; after subscription, the response topic enters a waiting for response state, and the response topic is used to monitor whether a response message arrives.
[0054] Exemplarily, a request message with an ID value is sent to a preset topic, which can be subscribed and received by other subscribers (e.g., industrial gateways, IoT devices, or other applications). In addition to publishing request messages, the cloud server also subscribes to the response topic related to the request message to receive the reply message related to the request. After subscription, the response topic enters the waiting for reply state and continuously monitors the message stream on the response topic. It is worth noting that the ID value is used to identify each request message and its corresponding reply message.
[0055] For example, if a response message matching the request message is received, the response message is further processed, for example, parsing the response content, updating the local state, or displaying the result to the user. If no response message is received, further actions may be taken according to the preset retry strategy, for example, resending the request message or reporting an error to the user. That is, the subscriber can only receive response messages when they are sent to the response topic.
[0056] For example, when the cloud server wants to obtain the alarm information of the industrial device "Device001" for monitoring and fault warning, it constructs an MQTT message using the Property field introduced in the MQTT5.0 version, and attaches an ID value "REQ12345" in the Property field. It then sends the message to the specified topic "Device / Device001 / Alarm Request" and subscribes to the response topic "Device / Response" at the same time. Then, it enters the waiting for response state.
[0057] In step S200, the industrial gateway subscribes to a preset topic published by the cloud server, and receives a request message published by the cloud server when the cloud server publishes a request message to the preset topic.
[0058] Exemplarily, after subscribing to a preset topic, the industrial gateway maintains a connection and monitors the message stream on the topic, so that when the cloud server publishes a request message, it can promptly receive the request message sent by the cloud server. For example, the content of the request message may include various instructions or query requirements that the cloud server instructs the industrial gateway to execute, depending on the operations that the cloud server requires the industrial gateway to perform.
[0059] Step S300, generating a response message based on the request message, and sending the response message to the response topic of the cloud server.
[0060] Exemplarily, after receiving the request message, the industrial gateway parses the request message, extracts the necessary instruction information, and then performs corresponding operations according to the instructions. For example, query the status of industrial device Device001, control Device002, update the status of Device003, and so on. After obtaining the data of the industrial device, the industrial gateway can also further process the data, such as data cleaning, format conversion, encryption and decryption, etc. Then generate a response message according to the processing result. The response message contains the result or execution status of the cloud server request so that the cloud server can understand the execution status of the requested device. For example, the response message can also include the following content: Response status: indicates whether the request is successfully processed; Processing result: The request is successful, which may include the operation result or query data. The request failed, which may include an error code and an error description. Response ID: Ideally, it matches the ID of the request message to ensure that the response corresponds to the request, etc. Finally, the response message is sent to the response topic of the cloud server or the specified queue for response. For example, before sending the response message, verification can also be performed to ensure the integrity and correctness of the response message.
[0061] For example, after receiving the request, the industrial gateway subscribed to the "Device / Device001 / Alarm Request" topic queries the device alarm information, encapsulates the queried alarm information into an MQTT reply message, and sends it to the response topic "Device / Response". The Property field of the message includes "REQ12345" so that the cloud server can recognize that this is a response to its request.
[0062] In an optional embodiment, after receiving a request message published by a cloud server based on a subscribed preset topic, the method further includes:
[0063] Parse the request message and obtain the ID value provided by the cloud server; the ID value is used to uniquely identify the request message.
[0064] Exemplarily, after receiving the request message, the industrial gateway will perform corresponding processing according to the content of the request message, such as parsing the message, querying the device alarm information, verifying the legitimacy of the request message, preparing the response message, etc. After the parsing process, the industrial gateway will obtain the processing result corresponding to the request message, for example, querying the current status of the industrial device Device001, obtaining the unique ID value provided by the cloud server, etc. The specific processing steps depend on the function and configuration of the industrial gateway. It is worth noting that the main function of the ID value is to serve as a unique identifier between the request message and the response message, uniquely identifying the request message and its corresponding response message, which means that at the same time or at different times, even if the cloud server sends multiple request messages to the industrial gateway, each message can be distinguished by its unique ID value.
[0065] In an optional embodiment, a response message is constructed according to the request message, and a response topic of sending the response message to the cloud server includes:
[0066] Construct a response message, add the ID value to the response message, and send it to the response topic.
[0067] Exemplarily, after the processing is completed, the industrial gateway will construct a response message and attach the unique ID value received from the cloud server to the response message so that the cloud server can understand the execution of the request. In addition to the unique ID value, the response message may also contain the processing results of the request, status information, data, or any other information that needs to be returned to the cloud server. The unique ID value is attached by adding a user-defined attribute in the attribute field of the response message, or the ID value is included as part of the message body (Payload), depending on the message format and the communication protocol agreement. The industrial gateway then sends the constructed response message to the specified response topic, so that the cloud server verifies the response message and the request message, so that it is easier to associate the original request and response when verifying consistency in subsequent steps, ensuring the integrity and accuracy of the message.
[0068] Step S400, when the cloud server receives the response message returned by the industrial gateway, it verifies the response message and the request message; when the response message is verified to be consistent with the request message, it responds to the request message.
[0069] Exemplarily, in order to ensure the integrity and accuracy of the data, the cloud server will verify the received response message with the previous request message. For example, check whether the format, content, sequence number or other identifiers of the request message match. If the response message is consistent with the request message verification result, it means that the message is complete and correct, and then respond to the original request message. Otherwise, it cannot respond to the original request message.
[0070] In an optional embodiment, after sending the request message with the ID value added to the attribute field to the preset topic and subscribing to the response topic of the request message, the method further includes:
[0071] When a response message is received from the industrial gateway, the callback thread is entered, and the response message is processed in the callback thread to extract the ID value in the response message.
[0072] Exemplarily, since the cloud server has subscribed to the response topic, the cloud server can receive reply messages from the industrial gateway. When it monitors the reply message returned by the industrial gateway, it enters the callback thread. In the callback thread, it parses the attribute field of the reply message and extracts the unique ID value in the Property field.
[0073] In an optional embodiment, the response message and the request message are verified, and when the response message and the request message are verified to be consistent, responding to the request message includes:
[0074] Verify whether the ID value in the response message is consistent with the ID value in the request message; respond to the request message if the ID value in the response message is consistent with the ID value in the request message.
[0075] Exemplarily, the ID value is used to uniquely identify each request message and its corresponding response message. Therefore, the source of the message is verified by comparing the ID value of the request message and the ID value of the response message. That is, if the verification ID value is consistent, it means that the response message is a correct response to the request message, and the cloud server responds to the original request message. If the verification ID value is inconsistent, the message cannot be responded to, and it may be necessary to record the error, notify the user, or take other error handling measures. By verifying the ID value, the association between the response message and the request message can be ensured, and only verified messages can be correctly processed and responded to, thereby improving the reliability and accuracy of the system.
[0076] For example, the cloud server receives a response message on the subscribed "Device / Response" topic, enters the callback thread, extracts the "Request ID" in the Property field, and compares it with the "REQ12345" currently waiting in the cloud server. If the "Request ID" matches, the cloud server can confirm that it is a response to its own request and can accurately respond to the request. If it is inconsistent with the "REQ12345" currently waiting in the cloud server, the Request ID does not match, and the cloud server cannot confirm the response to its own request, so it does not respond to the request.
[0077] It is worth noting that the above ID values are just examples and can be adjusted adaptively according to specific circumstances.
[0078] The processing method based on the MQTT protocol of the embodiment of the present application uses the MQTT protocol to build a direct request and response mechanism, in which the cloud server publishes a request message to a preset topic based on the MQTT protocol and subscribes to the response topic of the request message. The industrial gateway subscribes to the preset topic published by the cloud server, receives the request message based on the preset topic, and then generates a reply message according to the request message, and sends the reply message to the response topic of the cloud server, so that the cloud server verifies the reply message and the request message, and responds to the request message when the verification is consistent. This mechanism ensures efficient, stable and reliable message transmission between the cloud server and the industrial gateway, ensures the immediacy of requests and responses, significantly improves the speed and accuracy of responses, brings a smoother experience to users, and provides a solid communication foundation for various application scenarios.
[0079] It can be understood that the method of this embodiment corresponds to a processing system based on the MQTT protocol in the above embodiment, and the options in the above embodiment are also applicable to this embodiment, so they will not be described repeatedly here.
[0080] The present application also provides a computer device. Exemplarily, the computer device includes a processor and a memory, wherein the memory stores a computer program, and the processor runs the computer program to enable the terminal device to execute the functions of each module in the above-mentioned processing method based on the MQTT protocol or the above-mentioned processing system based on the MQTT protocol.
[0081] Among them, the processor can be an integrated circuit chip with signal processing capabilities. The processor can be a general-purpose processor, including a central processing unit (CPU), a graphics processing unit (GPU) and a network processor (NP), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or at least one of other programmable logic devices, discrete gates or transistor logic devices, and discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc., which can implement or execute the disclosed methods, steps and logic block diagrams in the embodiments of the present application.
[0082] The memory may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), etc. The memory is used to store a computer program, and the processor may execute the computer program accordingly after receiving an execution instruction.
[0083] The present application also provides a computer-readable storage medium for storing the computer program used in the above-mentioned terminal device. For example, the computer-readable storage medium may include, but is not limited to, various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0084] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and structure diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in an alternative implementation, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the structure diagram and / or the flow diagram, and the combination of boxes in the structure diagram and / or the flow diagram, can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0085] In addition, the functional modules or units in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0086] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a smart phone, a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the various embodiments of the present application.
[0087] The above description is only a specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.
Claims
1. A processing method based on the MQTT protocol, characterized in that: include: Publish request messages to the preset topic based on the MQTT protocol and subscribe to the response topic; Receive a response message returned by the industrial gateway that subscribes to the preset topic; The response message and the request message are verified, and the request message is responded to when the response message and the request message are verified to be consistent.
2. The processing method based on the MQTT protocol according to claim 1, characterized in that: Publishing a request message to a preset topic based on the MQTT protocol and subscribing to a response topic includes: Construct a request message based on the MQTT protocol, and add an ID value in the attribute field of the request message; wherein the ID value is used to uniquely identify the request message; The request message with the ID value added in the attribute field is sent to the preset topic, and the response topic of the request message is subscribed; after subscription, the response topic enters a waiting for response state to monitor whether a response message arrives.
3. The processing method based on the MQTT protocol according to claim 2, characterized in that: After sending the request message with the ID value added in the attribute field to the preset topic and subscribing to the response topic of the request message, the method further includes: When a response message returned by the industrial gateway is received, a callback thread is entered, and the response message is processed in the callback thread to extract the ID value in the response message.
4. The processing method based on the MQTT protocol according to claim 1, characterized in that: The verifying the response message and the request message, and responding to the request message when the response message and the request message are verified to be consistent, comprises: Verify whether the ID value in the response message is consistent with the ID value in the request message; When the ID value in the response message is consistent with the ID value in the request message, the request message is responded to.
5. A processing method based on the MQTT protocol, characterized in that: include: Subscribe to the preset topics published by the cloud server; Receive a request message published by the cloud server based on the subscribed preset topic; A response message is constructed based on the request message, and the response message is sent to the response topic of the cloud server. The response topic is used by the cloud server to verify whether the response message is consistent with the request message, and respond to the request message when the verification is consistent.
6. The processing method based on the MQTT protocol according to claim 5, characterized in that: After the subscription-based preset topic receives the request message published by the cloud server, the method further includes: Parse the request message to obtain the ID value provided by the cloud server; The ID value is used to uniquely identify the request message.
7. The processing method based on the MQTT protocol according to claim 5, characterized in that: The step of constructing a response message according to the request message and sending the response message to the response topic of the cloud server includes: Construct a response message, add the ID value to the response message, and send it to the response topic of the cloud server.
8. A processing system based on the MQTT protocol, characterized in that: The system comprises: The cloud server is used to publish request messages to preset topics based on the MQTT protocol and subscribe to response topics; The industrial gateway is used to subscribe to the preset topic published by the cloud server, and receive the request message published by the cloud server when the cloud server publishes the request message to the preset topic; The industrial gateway is further used to generate a response message according to the request message, and send the response message to the response topic of the cloud server; The cloud server is also used to verify the response message and the request message when receiving the response message returned by the industrial gateway; and respond to the request message when the response message is verified to be consistent with the request message.
9. A computer device, characterized in that: The computer device comprises a processor and a memory, wherein the memory stores a computer program, and the processor is configured to execute the computer program to implement the processing method based on the MQTT protocol according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: It stores a computer program, which, when executed on a processor, implements the processing method based on the MQTT protocol according to any one of claims 1 to 7.