An instant messaging method, server, client and system based on MQTT protocol
By adding the acknowledge message ID in the payload in the acknowledge message PUBACK packet of the MQTT protocol, the problem of missing message ID in the prior art is solved, and the convenience of instant messaging message management is improved.
Patent Information
- Application Number
- CN202411358838.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-27
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2044-09-27
AI Technical Summary
In instant messaging applications, the lack of acknowledgement message ID of the existing MQTT protocol causes the server and client to increase the message sending and processing volume, which is inconvenient to manage.
By adding payload in the acknowledge message PUBACK packet, including at least 8 bytes of the acknowledge message PUBACK packet, the server and client can obtain and manage the message ID to reduce unnecessary message sending.
Improves the convenience of instant messaging message management, without increasing the number of messages sent, and the server and client can easily manage the returned messages.
Smart Images

Figure CN118890389B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of satellite observation technology, and in particular to an instant messaging method, server, client and system based on the MQTT protocol. Background Art
[0002] Message Queuing Telemetry Transport (MQTT) is a message protocol based on the Publish / Subscribe paradigm and developed by the International Organization for Standardization based on the ISO / IEC PRF 20922 standard. The MQTT protocol is lightweight, simple, open, and easy to implement, which makes it widely applicable. Based on these advantages, the MQTT protocol can also be applied to instant messaging of multiple clients. However, in the process of instant messaging applications, due to the interaction between multiple clients and servers, when the instant messaging client publishes a message (PUBLISH), the instant messaging server can only confirm the receipt of the message (PUBACK), and the confirmation message has no identification (confirmation message ID). If the confirmation message ID needs to be returned, the server needs to publish a message with an ID through PUBLISH, and the client needs to confirm the receipt of the message through PUBACK, so that the client and server can complete the operation of sending messages and recording IDs, which increases the message sending and processing volume of the server and client, and is very inconvenient for the client and server to manage messages. Summary of the invention
[0003] In order to solve the above problems existing in the prior art, the present invention provides an instant messaging method, server, client and system based on the MQTT protocol. The technical problem to be solved by the present invention is achieved through the following technical solutions:
[0004] A first aspect of an embodiment of the present invention provides an instant messaging method based on the MQTT protocol, which is applied to a server and includes the following steps:
[0005] Receive the message data PUBLISH package sent by the client;
[0006] Sending a confirmation message PUBACK packet to the client; wherein the confirmation message PUBACK packet includes a valid load, and the valid load includes an identification of the confirmation message PUBACK packet of at least 8 bytes.
[0007] A second aspect of an embodiment of the present invention provides an instant messaging method based on the MQTT protocol, which is applied to a client and includes the following steps:
[0008] Receive a confirmation message PUBACK packet sent by the server; wherein the confirmation message PUBACK packet includes a valid load, and the valid load includes an identifier of the confirmation message PUBACK packet of at least 8 bytes;
[0009] Parsing the confirmation message PUBACK packet;
[0010] Determine whether the remaining byte length of the confirmation message PUBACK packet is greater than or equal to a preset byte length; wherein the preset byte length is greater than or equal to 10 bytes;
[0011] If it is greater than or equal to the preset byte length, a correspondence between its own message data and the identifier of the confirmation message PUBACK packet is constructed according to the confirmation message PUBACK packet and the effective load.
[0012] In one embodiment of the present invention, constructing a correspondence between its own message data and an identifier of the confirmation message PUBACK packet according to the confirmation message PUBACK packet and the effective load includes:
[0013] Read the variable message header of the confirmation message PUBACK packet to obtain the identifier of the message data PUBLISH packet;
[0014] Read the payload of the confirmation message PUBACK packet to obtain the identifier of the confirmation message PUBACK packet;
[0015] Determine its own message data according to the identifier of the message data PUBLISH package;
[0016] Construct a correspondence between the message data of the device itself and the identifier of the confirmation message PUBACK packet.
[0017] In one embodiment of the present invention, the method further includes: when the remaining byte length of the confirmation message PUBACK packet is less than a preset byte length, deleting the confirmation message PUBACK packet, and marking the message data corresponding to the variable header in the confirmation message PUBACK packet as sending failure.
[0018] In one embodiment of the present invention, the method further comprises:
[0019] In response to a processing operation on the message data, a processing message PUBLISH package is sent to the server; wherein the subject name in the processing message PUBLISH package indicates the processing operation, and the payload of the processing message PUBLISH package includes an identifier of a confirmation message PUBACK package corresponding to the message data; the processing operation includes a withdrawal operation or a deletion operation.
[0020] In one embodiment of the present invention, the subject name is 3 to 5 bytes;
[0021] The payload in the PUBLISH packet of the processing message is at least 8 bytes.
[0022] In one embodiment of the present invention, the method further comprises:
[0023] Send file data to the server via HTTP protocol;
[0024] A file data PUBLISH packet is sent to a server; wherein the effective load in the file data PUBLISH packet includes an HTTP link of the file data returned by the server.
[0025] A third aspect of an embodiment of the present invention provides an instant messaging server based on the MQTT protocol, comprising:
[0026] The first receiving module is used to receive the message data PUBLISH package sent by the client;
[0027] A sending module is used to send a confirmation message PUBACK packet to the client; wherein the confirmation message PUBACK packet includes a valid load, and the valid load includes an identification of the confirmation message PUBACK packet of at least 8 bytes.
[0028] A fourth aspect of an embodiment of the present invention provides an instant messaging client based on the MQTT protocol, comprising:
[0029] A second receiving module is used to receive a confirmation message PUBACK packet sent by the server; wherein the confirmation message PUBACK packet includes a valid load, and the valid load includes an identifier of the confirmation message PUBACK packet of at least 8 bytes;
[0030] A parsing module, used for parsing the confirmation message PUBACK packet;
[0031] A judging module, used to judge whether the remaining byte length of the confirmation message PUBACK packet is greater than or equal to a preset byte length; wherein the preset byte length is greater than or equal to 10 bytes;
[0032] The determination module is used to construct a corresponding relationship between its own message data and the identifier of the confirmation message PUBACK packet according to the confirmation message PUBACK packet and the effective load if it is greater than or equal to the preset byte length.
[0033] A fifth aspect of the embodiments of the present invention provides an instant messaging system based on the MQTT protocol, comprising: a server according to the third aspect of the embodiments of the present invention and a client according to the fourth aspect of the embodiments of the present invention.
[0034] Beneficial effects of the present invention:
[0035] The present invention carries the identifier of the confirmation message PUBACK packet through the effective load in the confirmation message PUBACK packet. Both the server and the client can obtain the identifier, and the messages returned by the server to the client can be managed on the local side through the identifier. Without increasing the amount of message sending, multiple clients and servers can each conveniently manage the messages returned by the server, thereby improving the convenience of instant messaging message management.
[0036] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings.
[0037] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0039] Figure 1 A flow chart of an instant messaging method based on the MQTT protocol provided by an embodiment of the present invention;
[0040] Figure 2 A schematic diagram of another instant messaging method based on the MQTT protocol provided by an embodiment of the present invention;
[0041] Figure 3 A block diagram of an instant messaging server based on the MQTT protocol provided by an embodiment of the present invention;
[0042] Figure 4 A block diagram of an instant messaging client based on the MQTT protocol provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0043] The present invention is further described in detail below with reference to specific embodiments, but the embodiments of the present invention are not limited thereto.
[0044] The present invention aims to provide a safe, efficient and real-time communication service. By using the instant messaging system, information can be quickly transmitted within the organization, the collaborative office capability can be improved, and strong support can be provided for the decision-making and action of the organization.
[0045] like Figure 1As shown, a first aspect of an embodiment of the present invention provides an instant messaging method based on the MQTT protocol, which is applied to a server and includes the following steps:
[0046] Step 11: Receive the message data PUBLISH package sent by the client.
[0047] Step 12: Send a confirmation message PUBACK packet to the client.
[0048] The confirmation message PUBACK packet includes a valid load, and the valid load includes an identifier of the confirmation message PUBACK packet of at least 8 bytes.
[0049] In this embodiment, the message level is QoS=1. The Quality of Service (QoS) of the MQTT message queue represents the service quality of message transmission. QoS=1 means that the message arrives at least once. This level ensures that the message arrives, but the message may be repeated. The instant messaging client PUBLISH publishes the message, and the instant messaging server PUBACK confirms the receipt of the message, and returns the server's confirmation message PUBACK packet identifier to the client through the Payload of the PUBACK message, which is the ID of the confirmation message PUBACK packet. Payload is the effective load.
[0050] It should be noted that the PUBACK packet is used by the server to feedback to the client to confirm that the message sent by the client has been received. The PUBACK packet and the PUBLISH packet are message data packets. In the prior art, there is no Payload and no PUBACK packet ID in the PUBACK packet returned by the server. When used in instant messaging, multiple clients need to send messages to the server, and the server needs feedback. However, each client has the same identification for the PUBLISH packet, and the server cannot manage it when returning the PUBACK packet. The confirmation message PUBACK packet of this embodiment adds a Payload to the prior art, and the Payload at least includes the ID of the confirmation message PUBACK packet. The server can obtain the identification of the confirmation message PUBACK packet to facilitate the management of the confirmation message.
[0051] like Figure 2 As shown, a second aspect of an embodiment of the present invention provides an instant messaging method based on the MQTT protocol, which is applied to a client and includes the following steps:
[0052] Step 21: Receive a confirmation message PUBACK packet sent by the server.
[0053] In this step, the client sends a message data PUBLISH packet to the server, and the server returns a confirmation message PUBACK packet to the client.
[0054] The confirmation message PUBACK packet includes a valid load, and the valid load includes an identifier of the confirmation message PUBACK packet of at least 8 bytes.
[0055] Step 22, parse the confirmation message PUBACK packet.
[0056] Step 23, determining whether the remaining byte length of the confirmation message PUBACK packet is greater than or equal to a preset byte length.
[0057] Among them, the preset byte length is greater than or equal to 10 bytes.
[0058] Step 24: If it is greater than or equal to the preset byte length, then a corresponding relationship between its own message data and the identifier of the confirmation message PUBACK packet is constructed according to the confirmation message PUBACK packet and the effective load.
[0059] In this embodiment, since the confirmation message PUBACK packet contains the Payload, the client needs to determine whether the remaining parsed byte length of the confirmation message PUBACK packet is valid when parsing. If it is valid, it means that the PUBACK packet is valid and usable. If it is invalid, the PUBACK packet is invalid and unusable. After confirming that the PUBACK packet is valid, a corresponding relationship between the message returned by the server and the local message data is established locally on the client to facilitate the subsequent management of all messages.
[0060] Here, in combination with the methods provided in the first and second aspects of the embodiments of the present invention, the instant messaging method for interaction between the server and the client of the present invention is described in detail. The third aspect of the embodiment of the present invention provides an instant messaging method based on the MQTT protocol, comprising the following steps: (the same contents as those in the first and second aspects of the embodiments of the present invention are not repeated here)
[0061] Step 31: The client sends a message data PUBLISH packet to the server.
[0062] Step 32: The server receives the message data PUBLISH packet sent by the client.
[0063] Step 33: The server sends a confirmation message PUBACK packet to the client.
[0064] The confirmation message PUBACK packet includes a payload, and the payload includes an identification of the confirmation message PUBACK packet of at least 8 bytes. Here, the payload can also carry other information, that is, the payload of the confirmation message PUBACK packet can be composed of the identification of the confirmation message PUBACK packet and other information. At this time, the bytes of the Payload are greater than 8, and the identification of the confirmation message PUBACK packet occupies at least 8 bytes.
[0065] In a feasible implementation, the identifier of the confirmation message PUBACK packet uses the long type, a total of 8 bytes, and occupies 64 bits, of which 43 bits are timestamps, 6 bits are node numbers, and 15 bits are sequence numbers. The identifier generated by the server is guaranteed to be incremental and unique. For example, the message data of the confirmation message PUBACK packet is shown in Table 1 below:
[0066]
[0067] Table 1
[0068] Among them, MSB and LSB represent the identifier of the message data PUBLISH packet, Byte represents byte, and Bit represents bit.
[0069] Step 34: The client receives a confirmation message PUBACK packet sent by the server.
[0070] Step 35: The client parses the confirmation message PUBACK packet.
[0071] Step 36: The client determines whether the remaining byte length of the confirmation message PUBACK packet is greater than or equal to the preset byte length.
[0072] The preset byte length is greater than or equal to 10 bytes. The remaining byte length is the bytes following the remaining length in Table 1.
[0073] When the client parses the message at the remaining byte length, it is determined whether the value of the remaining byte length in the message is greater than or equal to 10 bytes. For example, as shown in Table 1, the preset byte length is 10, and when the message is parsed to the remaining length, it is determined whether the value here is equal to 10.
[0074] Step 37: If the length is greater than or equal to the preset byte length, the client constructs a corresponding relationship between its own message data and the identifier of the confirmation message PUBACK packet according to the confirmation message PUBACK packet and the effective load. The specific steps of step 37 include: Step 371-Step 374:
[0075] Step 371: If it is greater than or equal to the preset byte length, the client reads the variable message header of the confirmation message PUBACK packet to obtain the identifier of the message data PUBLISH packet.
[0076] Step 372, the client reads the payload of the confirmation message PUBACK packet and obtains the identifier of the confirmation message PUBACK packet. Steps 371 and 372 parse the same confirmation message PUBACK packet, and the identifier of the message data PUBLISH packet obtained by parsing corresponds to the identifier of the confirmation message PUBACK packet.
[0077] Step 373, the client determines its own message data according to the identifier of the message data PUBLISH package. In this step, the client can find the local message data corresponding to the identifier according to the identifier of the message data PUBLISH package in the confirmation message PUBACK package.
[0078] Step 374, the client constructs a correspondence between its own message data and the identifier of the corresponding confirmation message PUBACK packet. In this step, the correspondence between the found own message data and the identifier of the corresponding confirmation message PUBACK packet is stored, so as to facilitate the subsequent relevant processing of the own message data corresponding to the identifier of the returned confirmation message PUBACK packet.
[0079] Step 38: When the remaining byte length of the confirmation message PUBACK packet is less than the preset byte length, the confirmation message PUBACK packet is deleted, and the message data corresponding to the variable header in the read confirmation message PUBACK packet is marked as sending failure.
[0080] In a feasible implementation manner, based on the above embodiment, the correspondence between the own message data and the identifier of the confirmation message PUBACK packet has been established. When the client wants to withdraw or delete the message data corresponding to the message data PUBLISH packet, the following steps are included:
[0081] Step A1: In response to a processing operation on message data, the client sends a processing message PUBLISH packet to the server.
[0082] The subject name in the processing message PUBLISH packet indicates the processing operation, and the effective load includes the identifier of the confirmation message PUBACK packet corresponding to the message data; the processing operation includes a withdrawal operation or a deletion operation.
[0083] In this step, after the user performs the withdrawal or deletion processing operation on the client, the client sends a processing message PUBLISH package to the server. Here, on the basis of the traditional PUBLISH package, the subject name of the PUBLISH package is given a new value, which can indicate the withdrawal or deletion operation, and the corresponding confirmation message PUBACK package identifier is carried in the Payload of the PUBLISH package (the corresponding relationship has been established in the above embodiment). In this way, when the server receives and reads the processing message PUBLISH package, the server can uniquely determine which confirmation message PUBACK package is to be withdrawn or deleted.
[0084] Preferably, the subject name is 3 to 5 bytes; the payload in the PUBLISH packet of the processing message is at least 8 bytes.
[0085] In a feasible implementation, during the instant messaging process, the client and the server can transmit text, pictures, videos and other information. The text can be carried in the Payload of the PUBLISH message. The pictures or videos form files, which are transmitted via the HTTP protocol (Hypertext Transfer Protocol) or the Hypertext Transfer Protocol Secure, and the links to the files are carried in the Payload of the PUBLISH message. Specifically, the following steps are included:
[0086] Step B1, the client sends file data to the server via HTTP protocol (or Hypertext Transfer Protocol Secure), wherein the file data includes relatively large files such as pictures, videos, and audios.
[0087] Step B2, the server receives the file data and generates a link, and then sends the link of the file data to the client via HTTP protocol (or Hypertext Transfer Protocol Secure);
[0088] Step B3: The client sends a file data PUBLISH packet to the server.
[0089] The payload in the file data PUBLISH packet includes an HTTP link of the file data.
[0090] In this embodiment, when transmitting large file data, the HTTP protocol and the MQTT protocol are used for transmission respectively. The HTTP protocol transmits the file data, and the MQTT protocol transmits the link message of the file data, so that the file data transmission is not easy to be lost. At the same time, if the file data is damaged, it will not affect the sending of the MQTT message with the link. The file data sent through the HTTP protocol will not occupy the resources of other messages of the MQTT protocol, forming resource isolation.
[0091] Here, after receiving the file data PUBLISH package, the server sends the message to other clients in the form of a PUBLISH package, which can also be understood as the server forwarding the file data PUBLISH package.
[0092] like Figure 3 As shown, a fourth aspect of an embodiment of the present invention provides an instant messaging server based on the MQTT protocol, comprising:
[0093] The first receiving module 41 is used to receive a message data PUBLISH packet sent by a client;
[0094] The sending module 42 is used to send a confirmation message PUBACK packet to the client; wherein the confirmation message PUBACK packet includes a valid load, and the valid load includes an identification of the confirmation message PUBACK packet of at least 8 bytes.
[0095] like Figure 4 As shown, the fifth aspect of the embodiment of the present invention provides an instant messaging client based on the MQTT protocol, including:
[0096] The second receiving module 51 is used to receive a confirmation message PUBACK packet sent by the server; wherein the confirmation message PUBACK packet includes a valid load, and the valid load includes an identification of the confirmation message PUBACK packet of at least 8 bytes;
[0097] A parsing module 52, configured to parse a confirmation message PUBACK packet;
[0098] The judging module 53 is used to judge whether the remaining byte length of the confirmation message PUBACK packet is greater than or equal to a preset byte length; wherein the preset byte length is greater than or equal to 10 bytes;
[0099] The determination module 54 is used to construct a corresponding relationship between its own message data and the identifier of the confirmation message PUBACK packet according to the confirmation message PUBACK packet and the effective load if it is greater than or equal to the preset byte length.
[0100] In one embodiment of the present invention, constructing a correspondence between its own message data and the identifier of the confirmation message PUBACK packet according to the confirmation message PUBACK packet and the effective load includes:
[0101] Read the variable header of the confirmation message PUBACK packet to obtain the identifier of the message data PUBLISH packet;
[0102] Read the payload of the confirmation message PUBACK packet and obtain the identifier of the confirmation message PUBACK packet;
[0103] Determine its own message data according to the identifier of the message data PUBLISH package;
[0104] Construct the correspondence between its own message data and the identifier of the confirmation message PUBACK packet.
[0105] In one embodiment of the present invention, it also includes: when the remaining byte length of the confirmation message PUBACK packet is less than the preset byte length, deleting the confirmation message PUBACK packet, and marking the message data corresponding to the variable header in the confirmation message PUBACK packet as sending failure.
[0106] In one embodiment of the present invention, it also includes:
[0107] In response to a processing operation on the message data, a processing message PUBLISH package is sent to the server; wherein the subject name in the processing message PUBLISH package indicates the processing operation, and the payload includes an identifier of a confirmation message PUBACK package corresponding to the message data; the processing operation includes a withdrawal operation or a deletion operation.
[0108] In one embodiment of the present invention, the subject name is 3 to 5 bytes; the payload in the processing message PUBLISH packet is at least 8 bytes.
[0109] In one embodiment of the present invention, the file data is sent to the server via the HTTP protocol;
[0110] A file data PUBLISH packet is sent to the server; wherein the effective load in the file data PUBLISH packet includes an HTTP link of the file data returned by the server.
[0111] A sixth aspect of an embodiment of the present invention provides an instant messaging system based on the MQTT protocol, including the server and client in the above embodiment of the present invention.
[0112] A seventh aspect of an embodiment of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, an instant messaging method based on the MQTT protocol provided in the above embodiment of the present invention is implemented.
[0113] An eighth aspect of an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of an instant messaging method based on the MQTT protocol provided in the above embodiment of the present invention are implemented.
[0114] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0115] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware systems.
[0116] The method provided in the embodiment of the present invention can be applied to electronic devices. Specifically, the electronic device can be: a desktop computer, a portable computer, an intelligent mobile terminal, a server, etc. This is not limited here, and any electronic device that can implement the present invention belongs to the protection scope of the present invention.
[0117] As for the system / electronic device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0118] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A system that specifies the functions of a box or multiple boxes.
[0119] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0120] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0121] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. An instant messaging method based on the MQTT protocol, applied to the client, It is characterized in that The following steps are involved: Receive a confirmation message PUBACK packet sent by the server; wherein the confirmation message PUBACK packet includes a valid load, and the valid load includes an identifier of the confirmation message PUBACK packet of at least 8 bytes; Parsing the confirmation message PUBACK packet; Determine whether the remaining byte length of the confirmation message PUBACK packet is greater than or equal to a preset byte length; wherein the preset byte length is greater than or equal to 10 bytes; If it is greater than or equal to the preset byte length, constructing a correspondence between its own message data and the identifier of the confirmation message PUBACK packet according to the confirmation message PUBACK packet and the effective load; The step of constructing a correspondence between the own message data and the identifier of the confirmation message PUBACK packet according to the confirmation message PUBACK packet and the effective load includes: Read the variable message header of the confirmation message PUBACK packet to obtain the identifier of the message data PUBLISH packet; Read the payload of the confirmation message PUBACK packet to obtain the identifier of the confirmation message PUBACK packet; Determine its own message data according to the identifier of the message data PUBLISH package; Constructing a correspondence between the own message data and the identifier of the confirmation message PUBACK packet; The method further includes: when the remaining byte length of the confirmation message PUBACK packet is less than a preset byte length, deleting the confirmation message PUBACK packet, and marking the message data corresponding to the variable header in the confirmation message PUBACK packet as sending failure; The method further comprises: In response to a processing operation on the message data, a processing message PUBLISH package is sent to the server; wherein the subject name in the processing message PUBLISH package indicates the processing operation, and the payload of the processing message PUBLISH package includes an identifier of a confirmation message PUBACK package corresponding to the message data; the processing operation includes a withdrawal operation or a deletion operation.
2. The method according to claim 1, It is characterized in that The subject name is 3 to 5 bytes; The payload in the PUBLISH packet of the processing message is at least 8 bytes.
3. The method according to claim 1, It is characterized in that The method further comprises: Send file data to the server via HTTP protocol; A file data PUBLISH packet is sent to a server; wherein the effective load in the file data PUBLISH packet includes an HTTP link of the file data returned by the server.
4. An instant messaging client based on the MQTT protocol, used to execute the instant messaging method as claimed in claim 1, It is characterized in that include: A second receiving module is used to receive a confirmation message PUBACK packet sent by the server; wherein the confirmation message PUBACK packet includes a valid load, and the valid load includes an identifier of the confirmation message PUBACK packet of at least 8 bytes; A parsing module, used for parsing the confirmation message PUBACK packet; A judging module, used to judge whether the remaining byte length of the confirmation message PUBACK packet is greater than or equal to a preset byte length; wherein the preset byte length is greater than or equal to 10 bytes; A determination module, configured to construct a correspondence between its own message data and an identifier of the confirmation message PUBACK packet according to the confirmation message PUBACK packet and the effective load if the length is greater than or equal to the preset byte length; The step of constructing a correspondence between the own message data and the identifier of the confirmation message PUBACK packet according to the confirmation message PUBACK packet and the effective load includes: Read the variable message header of the confirmation message PUBACK packet to obtain the identifier of the message data PUBLISH packet; Read the payload of the confirmation message PUBACK packet to obtain the identifier of the confirmation message PUBACK packet; Determine its own message data according to the identifier of the message data PUBLISH package; Constructing a correspondence between the own message data and the identifier of the confirmation message PUBACK packet; The method further includes: when the remaining byte length of the confirmation message PUBACK packet is less than a preset byte length, deleting the confirmation message PUBACK packet, and marking the message data corresponding to the variable header in the confirmation message PUBACK packet as sending failure; Also includes: In response to a processing operation on the message data, a processing message PUBLISH package is sent to the server; wherein the subject name in the processing message PUBLISH package indicates the processing operation, and the payload of the processing message PUBLISH package includes an identifier of a confirmation message PUBACK package corresponding to the message data; the processing operation includes a withdrawal operation or a deletion operation.
5. An instant messaging system based on the MQTT protocol, It is characterized in that include: A server and a client as claimed in claim 4.
Citation Information
Patent Citations
Instant messaging method and system
CN107786423A
Vehicle control method, server, client, vehicle and vehicle system
CN109327527A
Communication method and system of metering automation system, and storage medium
CN113141544A
Internet of vehicles data communication method, device, equipment and medium
CN116887351A
Real-time high-concurrency instant messaging method and device based on MQTT protocol and medium
CN117880232A
