Data transmission method and device, electronic equipment and storage medium
By detecting the packet size and network status of the request task, dynamically determine the long and short connections, and merging the same request task, the problems of high load and resource waste in the existing technology are solved, flexible communication strategies and efficient resource use are realized, and the improvement of User experience and communication efficiency.
Patent Information
- Application Number
- CN202411366862.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-01-03
AI Technical Summary
In the prior art, the frequent initiation of short connections and disconnections by clients increases communication overhead, resulting in communication blocking and delays under high load conditions, poor user experience, and multiple long connection requests are prone to waste of resources and delays.
By detecting the packet size and network status of the request task, dynamically decide whether to use long or short connections, and merge the same request tasks in the long connection request task queue, optimizing resource usage and reducing response time.
It realizes flexible communication strategies, automatically switch long and short connections, optimize resource usage, reduce network request response time, improve user experience and communication efficiency, and especially improve the fluency of client APPs in weak network environments.
Smart Images

Figure CN119254699A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a data transmission method, device, electronic equipment and storage medium. Background Art
[0002] Persistent connection and short connection are two different connection modes in network communication. They differ in establishing and maintaining the life cycle of the connection. A keep-alive connection means that the connection between the client and the server remains open for a period of time to allow multiple data transmissions. Persistent connection is suitable for situations where communication status and fast data transmission need to be maintained, but more server resources are required. Short connection means that the connection between the client and the server is closed immediately after a data transmission. Short connection is more suitable for saving resources and processing a large number of transient requests, but each connection establishment will bring a certain amount of overhead.
[0003] The current mainstream technology is that the data transmission between the client and the server is pre-agreed on the interface long connection request or short connection request according to the business type. However, if the client frequently initiates short connections and disconnects, it will increase the communication overhead, especially under high load. If the client initiates multiple long connection request tasks, it is easy to cause communication congestion, data transmission delay, and poor user experience. Summary of the invention
[0004] The present invention provides a data transmission method, device, electronic device and storage medium to solve the lack of flexibility in the prior art, provide a more flexible communication strategy, optimize resource usage and reduce network request response time, and realize automatic switching and dynamic management of long and short connections.
[0005] The present invention provides a data transmission method, comprising:
[0006] Get the target request task;
[0007] Detecting whether the size of the target request data packet in the target request task is less than or equal to a preset threshold;
[0008] If yes, determine that the target request task is a long connection request task; otherwise, determine that the target request task is a short connection request task, and initiate a short connection request;
[0009] When the target request task is a long connection request task, detecting whether there is a request task identical to the target request task in the long connection request task queue;
[0010] If so, there is no need to add the target request task to the persistent connection request task queue; otherwise, the target request task is added to the persistent connection request task queue to wait for initiating a persistent connection request.
[0011] According to a data transmission method provided by the present invention, when the target request task is a long connection request task, detecting whether there is a request task identical to the target request task in the long connection request task queue comprises:
[0012] Acquire the target request data packet, wherein the target request data packet includes: a service name, an interface name, and request parameters;
[0013] It is detected whether there is a request data packet identical to the target request data packet in the request task in the long connection request task queue.
[0014] According to a data transmission method provided by the present invention, after the step of adding the target request task to the long connection request task queue, the method further includes:
[0015] The result callback information in the target request task is saved in the long connection result callback information list.
[0016] According to a data transmission method provided by the present invention, otherwise, adding the target request task to the persistent connection request task queue to wait for initiating a persistent connection request, comprising:
[0017] If there is no request task identical to the target request task in the persistent connection request task queue, detecting whether the number of request tasks in the persistent connection request task queue is less than or equal to a preset number;
[0018] If so, the target request task is added to the long connection request task queue to wait for initiation of a long connection request; otherwise, a short connection request is initiated based on the target request task.
[0019] According to a data transmission method provided by the present invention, before detecting whether there is a request task identical to the target request task in the long connection request task queue, the method comprises:
[0020] Check whether the network status of the current persistent domain name is good;
[0021] If so, execute the step of detecting whether there is a request task identical to the target request task in the long connection request task queue; otherwise, initiate a short connection request based on the target request task.
[0022] According to a data transmission method provided by the present invention, the otherwise initiating a short connection request based on the target request task includes:
[0023] If the network condition of the current persistent connection is not good, obtain a persistent connection domain name list;
[0024] Detect whether there is a long connection domain name with good network status in the long connection domain name list;
[0025] If so, switch the current long connection domain name to a long connection domain name with good network status, establish a new long connection, and execute the step of detecting whether there is a request task identical to the target request task in the long connection request task queue; otherwise, initiate a short connection request based on the target request task.
[0026] According to a data transmission method provided by the present invention, an indicator for detecting whether the network status of the current long connection domain name is good includes at least one of the following: heartbeat packet response delay, interface response abnormality and error information, packet loss rate, and test round-trip delay.
[0027] The present invention also provides a data transmission device, comprising:
[0028] The acquisition module is used to obtain the target request task;
[0029] A first detection module, used to detect whether the size of the target request data packet in the target request task is less than or equal to a preset threshold;
[0030] A determination module, configured to determine, if yes, that the target request task is a long connection request task; otherwise, determine that the target request task is a short connection request task and initiate a short connection request;
[0031] A second detection module is used for detecting whether there is a request task identical to the target request task in the long connection request task queue when the target request task is a long connection request task;
[0032] The processing module is used for, if yes, there is no need to add the target request task to the long connection request task queue; otherwise, adding the target request task to the long connection request task queue to wait for initiating a long connection request.
[0033] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any of the data transmission methods described above is implemented.
[0034] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the data transmission method described in any one of the above methods is implemented.
[0035] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned data transmission methods.
[0036] The present invention provides a data transmission method, device, electronic device and storage medium. When data needs to be transmitted, a request task is created. By detecting the size of the request data packet in the target request task, it is determined whether to use a long connection request or a short connection request. When the size of the request data packet does not exceed the preset threshold, the target request task is determined to be a long connection request task; when it exceeds the preset threshold, the target request task is determined to be a short connection request task, and a short connection request is initiated. When the target request task is a long connection request task, it is necessary to detect whether there is a request task identical to the target request task in the long connection request task queue. If there is an identical request task, two identical request tasks are merged into one request task, and only the request task in the long connection request task queue needs to continue to wait for the initiation of a long connection request, and the target request task does not need to join the long connection request task queue. In this way, on the one hand, the advantages of long connection and short connection are combined to realize automatic switching, and the connection mode is dynamically selected according to the communication requirements; on the other hand, the same request tasks in the long connection are merged to effectively optimize resource usage and reduce network request response time, and the fluency of the client APP can be improved under a weak network, and the user experience can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0038] Figure 1 This is one of the flow charts of the data transmission method provided by the present invention;
[0039] Figure 2 This is the second flow chart of the data transmission method provided by the present invention;
[0040] Figure 3 It is a structural schematic diagram of a data transmission device provided by the present invention;
[0041] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0042] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0043] It should be noted that, in the description of the embodiments of the present invention, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "include one..." do not exclude the existence of other identical elements in the process, method, article or device including the elements. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to the specific circumstances.
[0044] The terms "first", "second", etc. in the present invention are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present invention can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of the same type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" means at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0045] Combine the following Figure 1-Figure 4 A data transmission method, device, electronic device and storage medium of the present invention are described.
[0046] like Figure 1 As shown, a data transmission method provided by the present invention can be applied to a client, and specifically comprises the following steps:
[0047] Step 110, obtaining the target request task.
[0048] Specifically, when the client needs to transmit data to the server, a request task is created. The target request task refers to a request task that has not been initiated.
[0049] Step 120 , detecting whether the size of the target request data packet in the target request task is less than or equal to a preset threshold.
[0050] Step 130: If yes, determine that the target request task is a long connection request task; otherwise, determine that the target request task is a short connection request task, and initiate a short connection request.
[0051] Specifically, the request task includes a request data packet and result callback information. After the request task is created, the size of the request data packet in the request task is detected to preliminarily determine whether to use a long connection or a short connection to initiate the request.
[0052] If the size of the request data packet does not exceed the preset threshold, it is determined to use a long connection to transmit data, and the request task is a long connection request task; if the size of the request data packet exceeds the preset threshold, it is determined to use a short connection to transmit data, and the request task is a short connection request task, and a short connection request can be directly initiated.
[0053] It is important to understand that when the size of a request packet is too large, using a long connection for transmission will occupy the entire long connection communication channel for a long time, blocking the initiation of other long connection requests. Therefore, by setting a threshold for the size of the request packet, a request packet that is too large uses a short connection to transmit data, avoiding the long connection transmission that takes up a long time, causing the communication channel to be blocked, and reducing the network request response time.
[0054] It is understandable that when executing step 130, it is detected that the size of the request data packet exceeds the preset threshold, a short connection request is initiated, and there is no need to execute steps 140-150.
[0055] Step 140: When the target request task is a persistent connection request task, it is detected whether there is a request task identical to the target request task in the persistent connection request task queue.
[0056] In some embodiments, step 140 specifically includes the following steps: obtaining the target request data packet, wherein the target request data packet includes: a service name, an interface name, and request parameters; and detecting whether there is a request data packet identical to the target request data packet in the request task in the long connection request task queue.
[0057] Specifically, the request data packet includes: service name, interface name and request parameters. Whether there is a request task identical to the target request task in the persistent connection request task queue, that is, whether the above contents of the request data packet are completely consistent.
[0058] Step 150: If yes, there is no need to add the target request task to the persistent connection request task queue; otherwise, add the target request task to the persistent connection request task queue and wait for initiating a persistent connection request.
[0059] Specifically, if it is detected that there is a request task identical to the target request task in the persistent connection request task list, the target request task does not need to be added to the persistent connection request task queue. In other words, it is equivalent to merging two identical request tasks and only needs to initiate one persistent connection request, thereby improving communication efficiency.
[0060] On the contrary, if there is no identical request task in the persistent connection request task list, the target request task is added to the persistent connection request task queue, waiting for initiation of a persistent connection request.
[0061] For example, when the client initiates multiple requests to obtain ranking list information at the same time, a long connection request is used. If the first interface to obtain the ranking list has not responded, the interfaces to obtain the ranking list initiated later can be merged and waited for. Only one request is required. The server returns the same response data to the client, and the client returns the callback information to each request based on the result of each request. In this way, the length of the long connection request task queue can be reduced, which can not only reduce the queuing time of other tasks, but also reduce the server response pressure, and also reduce user traffic consumption.
[0062] The present invention provides a data transmission method. When a client needs to transmit data to a server, a request task is created. By detecting the size of a request data packet in a target request task, it is determined whether a long connection request or a short connection request is adopted. When the size of the request data packet does not exceed a preset threshold, the target request task is determined to be a long connection request task; when it exceeds the preset threshold, the target request task is determined to be a short connection request task, and a short connection request is initiated. When the target request task is a long connection request task, it is necessary to detect whether there is a request task identical to the target request task in the long connection request task queue. If there is an identical request task, two identical request tasks are merged into one request task, and only the request task in the long connection request task queue needs to continue to wait for the initiation of a long connection request, and the target request task does not need to join the long connection request task queue. In this way, on the one hand, the advantages of long connection and short connection are combined to realize automatic switching, and the connection mode is dynamically selected according to the communication requirements; on the other hand, the same request tasks in the long connection are merged to request, effectively optimize resource utilization and reduce network request response time, improve communication efficiency, and improve the fluency of the client APP under a weak network, and improve user experience.
[0063] In some embodiments, after the step of: if so, there is no need to add the target request task to the persistent connection request task queue, the step further includes: saving the result callback information in the target request task into a persistent connection result callback information list.
[0064] Specifically, the request task includes a request data packet and result callback information. If it is determined that the request data packet content of the target request task is exactly the same as that of a request task in the list, the client needs to save the result callback information of the target request task to the long connection result callback information list. When the response result of the server is returned to the client, the client can call the result callback information and feedback it to the corresponding business according to the result callback information.
[0065] It is important to understand that the result callback information of each request task is unique. Therefore, even if a persistent connection is initiated, the client can accurately feed back the response results to the business corresponding to different request tasks based on the recorded result callback information.
[0066] In order to reduce the network request response time, in some embodiments, otherwise, adding the target request task to the persistent connection request task queue to wait for initiating a persistent connection request includes:
[0067] If there is no request task identical to the target request task in the persistent connection request task queue, detecting whether the number of request tasks in the persistent connection request task queue is less than or equal to a preset number;
[0068] If so, the target request task is added to the long connection request task queue to wait for initiation of a long connection request; otherwise, a short connection request is initiated based on the target request task.
[0069] Specifically, if there is no identical request task in the long connection request task queue, then check whether the number of request tasks in the long connection request task queue exceeds the preset number. If it does not exceed the preset number, the target request task is added to the long connection request task queue to wait for the request; if it exceeds the preset number, the long connection request is not used, and the short connection is used to initiate the request instead. By controlling the number of tasks in the long connection request task queue, the waiting time for the request task is avoided to be too long and the response is too slow, thereby improving the user experience.
[0070] In order to ensure effective communication, in some embodiments, before detecting whether there is a request task identical to the target request task in the long connection request task queue, the process includes:
[0071] Check whether the network status of the current persistent domain name is good;
[0072] If so, execute the step of detecting whether there is a request task identical to the target request task in the long connection request task queue; otherwise, initiate a short connection request based on the target request task.
[0073] Specifically, the indicator for detecting whether the network status of the current persistent connection domain name is good includes at least one of the following: heartbeat packet response delay, interface response abnormality and error information, packet loss rate, and test round-trip delay.
[0074] Conditions for judging whether the long connection network status is good:
[0075] 1) Heartbeat mechanism: The network status is determined by sending heartbeat packets regularly and receiving responses from the server within a certain period of time. If the delay between the heartbeat request and response is small and stable, the network status can be considered good.
[0076] 2) Based on interface response anomalies and errors: Monitor the interface request and judge the network status based on the anomalies and error information of the server response. If the interface request delay is small and the request is stable, the network status can be considered good.
[0077] 3) Check the packet loss rate: Low packet loss rate usually means a good network connection.
[0078] 4) Test the round-trip time (RTT): A smaller RTT value indicates a better network status.
[0079] Similarly, before initiating a short connection request based on the target request task, it is also possible to detect whether the network status of the current long connection domain name is good.
[0080] Conditions for judging whether the short connection network status is good:
[0081] 1) Based on interface response anomalies and errors: Monitor the interface request and judge the network status based on the anomalies and error information of the server response. If the interface request delay is small and the request is stable, the network status can be considered good.
[0082] 2) Check the packet loss rate: Low packet loss rate usually means a good network connection.
[0083] 3) Test the round-trip delay (RTT): A smaller RTT value indicates a better network status.
[0084] 4) Connection establishment time: Measures the time it takes from initiating a connection request to establishing a connection. A lower connection establishment time usually indicates a better network status.
[0085] 5) HTTP (Hypertext Transfer Protocol) status code: Check the HTTP status code returned by the server.
[0086] In some embodiments, the otherwise initiating a short connection request based on the target request task includes:
[0087] If the network condition of the current persistent connection is not good, obtain a persistent connection domain name list;
[0088] Detect whether there is a long connection domain name with good network status in the long connection domain name list;
[0089] If so, switch the current long connection domain name to a long connection domain name with good network status, establish a new long connection, and execute the step of detecting whether there is a request task identical to the target request task in the long connection request task queue; otherwise, initiate a short connection request based on the target request task.
[0090] In this embodiment, if the current long connection network condition is not good, the long connection domain name list is retrieved, a long connection domain name with a good network condition is found, and the long connection domain name with a good network condition is switched to establish a new long connection. If there is no long connection domain name with a good network condition, the short connection is switched to initiate the request. In this way, it is ensured that the long connection can be used to initiate the request, which can reduce the overhead of short connection communication, especially under high load conditions.
[0091] Figure 2 FIG. 1 is a flow chart of an exemplary embodiment of the present invention. Figure 2 As shown, when the client initiates a network request, it first determines whether the size of the data packet to be used to initiate the network request exceeds a preset threshold. If it exceeds a preset threshold, a short connection request is initiated using a short connection domain name with a good network status.
[0092] If the network request data packet does not exceed the preset threshold and is suitable for initiating a persistent connection request, the persistent connection heartbeat mechanism is used to detect whether the current persistent connection network status is good. If the network status is good, there is no need to switch the persistent connection domain name. If the network status is not good, check whether there is a persistent connection domain name with a good network status. If a persistent connection domain name with a good network status is available, switch the persistent connection domain name to re-establish a new persistent connection. If not, use the short connection domain name with a good network status to initiate a short connection request.
[0093] When it is determined that the long connection network is in good condition, check whether there are identical request tasks in the long connection request list. If so, merge the long connection request tasks to improve communication efficiency. If no identical request tasks are found in the long connection task queue, check whether the number of tasks in the long connection task queue exceeds the threshold. If not, directly add them to the long connection task queue and wait for the initiation of a long connection. Otherwise, initiate a short connection request.
[0094] The data transmission device provided by the present invention is described below. The data transmission device described below and the data transmission method described above can be referenced to each other.
[0095] like Figure 3As shown, the present invention also provides a data transmission device, comprising:
[0096] An acquisition module 310 is used to acquire a target request task;
[0097] A first detection module 320, used to detect whether the size of the target request data packet in the target request task is less than or equal to a preset threshold;
[0098] A determination module 330 is used to determine that if yes, the target request task is a long connection request task; otherwise, determine that the target request task is a short connection request task and initiate a short connection request;
[0099] A second detection module 340 is used to detect whether there is a request task identical to the target request task in the long connection request task queue when the target request task is a long connection request task;
[0100] The processing module 350 is used for: if yes, there is no need to add the target request task to the long connection request task queue; otherwise, adding the target request task to the long connection request task queue to wait for initiating a long connection request.
[0101] Figure 4 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 4 As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communication interface 420 and the memory 430 complete mutual communication through the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute the data transmission method, which includes: obtaining a target request task; detecting whether the size of the target request data packet in the target request task is less than or equal to a preset threshold; if so, determining that the target request task is a long connection request task; otherwise, determining that the target request task is a short connection request task and initiating a short connection request; when the target request task is a long connection request task, detecting whether there is a request task identical to the target request task in the long connection request task queue; if so, there is no need to add the target request task to the long connection request task queue; otherwise, adding the target request task to the long connection request task queue to wait for initiating a long connection request.
[0102] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, 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 personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: 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 disk or an optical disk.
[0103] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the data transmission method provided by the above-mentioned methods, which includes: obtaining a target request task; detecting whether the size of a target request data packet in the target request task is less than or equal to a preset threshold; if so, determining that the target request task is a long connection request task; otherwise, determining that the target request task is a short connection request task, and initiating a short connection request; when the target request task is a long connection request task, detecting whether there is a request task identical to the target request task in the long connection request task queue; if so, there is no need to add the target request task to the long connection request task queue; otherwise, adding the target request task to the long connection request task queue to wait for initiation of a long connection request.
[0104] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a data transmission method provided by the above-mentioned methods, the method comprising: obtaining a target request task; detecting whether the size of a target request data packet in the target request task is less than or equal to a preset threshold; if so, determining that the target request task is a long connection request task; otherwise, determining that the target request task is a short connection request task, and initiating a short connection request; when the target request task is a long connection request task, detecting whether there is a request task identical to the target request task in the long connection request task queue; if so, there is no need to add the target request task to the long connection request task queue; otherwise, adding the target request task to the long connection request task queue to wait for initiation of a long connection request.
[0105] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0106] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0107] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A data transmission method, characterized in that: include: Get the target request task; Detecting whether the size of the target request data packet in the target request task is less than or equal to a preset threshold; If so, determining that the target request task is a long connection request task; Otherwise, determining that the target request task is a short connection request task, and initiating a short connection request; When the target request task is a long connection request task, detecting whether there is a request task identical to the target request task in the long connection request task queue; If so, there is no need to add the target request task to the persistent connection request task queue; otherwise, the target request task is added to the persistent connection request task queue to wait for initiating a persistent connection request.
2. The data transmission method according to claim 1, characterized in that: When the target request task is a persistent connection request task, detecting whether there is a request task identical to the target request task in the persistent connection request task queue comprises: Acquire the target request data packet, wherein the target request data packet includes: a service name, an interface name, and request parameters; It is detected whether there is a request data packet identical to the target request data packet in the request task in the long connection request task queue.
3. The data transmission method according to claim 1, characterized in that: After the step of adding the target request task to the long connection request task queue, the method further includes: The result callback information in the target request task is saved in the long connection result callback information list.
4. The data transmission method according to claim 1, characterized in that: Otherwise, adding the target request task to the persistent connection request task queue to wait for initiating a persistent connection request, including: If there is no request task identical to the target request task in the persistent connection request task queue, detecting whether the number of request tasks in the persistent connection request task queue is less than or equal to a preset number; If so, the target request task is added to the long connection request task queue to wait for initiation of a long connection request; otherwise, a short connection request is initiated based on the target request task.
5. The data transmission method according to claim 1, characterized in that: Before detecting whether there is a request task identical to the target request task in the long connection request task queue, the method includes: Check whether the network status of the current persistent domain name is good; If so, execute the step of detecting whether there is a request task identical to the target request task in the long connection request task queue; otherwise, initiate a short connection request based on the target request task.
6. The data transmission method according to claim 5, characterized in that: Otherwise, initiating a short connection request based on the target request task includes: If the network condition of the current persistent connection is not good, obtain a persistent connection domain name list; Detect whether there is a long connection domain name with good network status in the long connection domain name list; If so, switch the current long connection domain name to a long connection domain name with good network status, establish a new long connection, and execute the step of detecting whether there is a request task identical to the target request task in the long connection request task queue; otherwise, initiate a short connection request based on the target request task.
7. The data transmission method according to claim 5, characterized in that: The indicator for detecting whether the network status of the current persistent connection domain name is good includes at least one of the following: heartbeat packet response delay, interface response abnormality and error information, packet loss rate, and test round-trip delay.
8. A data transmission device, characterized in that: include: The acquisition module is used to obtain the target request task; A first detection module, used to detect whether the size of the target request data packet in the target request task is less than or equal to a preset threshold; A determination module, configured to determine, if yes, that the target request task is a long connection request task; Otherwise, determining that the target request task is a short connection request task, and initiating a short connection request; A second detection module is used for detecting whether there is a request task identical to the target request task in the long connection request task queue when the target request task is a long connection request task; The processing module is used for, if yes, there is no need to add the target request task to the long connection request task queue; otherwise, adding the target request task to the long connection request task queue to wait for initiating a long connection request.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the data transmission method according to any one of claims 1 to 7 is implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the data transmission method according to any one of claims 1 to 7 is implemented.
