Heartbeat interval processing method and system based on long connection and storage medium
By monitoring device resources and network quality in real time and dynamically adjusting the heartbeat interval, the problems of high energy consumption and poor stability in traditional long-connection communication are solved, achieving more efficient energy management and connection stability.
Patent Information
- Application Number
- CN202510871700.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-26
- Publication Date
- 2025-11-04
AI Technical Summary
Traditional long-connection communication suffers from high energy consumption and poor connection stability due to the fixed heartbeat interval, especially since it cannot adaptively adjust when the network environment and device load change.
By monitoring device resource pressure indicators and network quality indices in real time, the target heartbeat interval is dynamically calculated. Combined with an LSTM time series model, network quality is predicted, and the heartbeat frequency is optimized to adapt to the current environment.
It effectively reduces unnecessary communication energy consumption, improves the stability of long connections, and avoids the problem of disconnection due to timeout.
Smart Images

Figure CN120896885A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer network communication, and particularly relates to a heartbeat interval processing method and system based on a long connection and a storage medium. BACKGROUND
[0002] In a traditional long connection communication mechanism, a fixed heartbeat interval is usually used to maintain the connection state between a client and a server. However, this method has the following problems:
[0003] 1. Regardless of the network environment or the device load, the heartbeat packet is sent at the same frequency, causing unnecessary power consumption;
[0004] 2. In the case of poor network quality, high-frequency heartbeat is still maintained, which can easily lead to unstable connection or even disconnection;
[0005] Therefore, there is an urgent need for a method that can adaptively adjust the heartbeat frequency to improve the stability of the long connection. SUMMARY
[0006] Embodiments of the present application provide a heartbeat interval processing method and system based on a long connection and a storage medium, aiming to solve the problem of high energy consumption and poor long connection stability caused by the traditional fixed heartbeat interval.
[0007] In a first aspect, the embodiments of the present application provide a heartbeat interval processing method based on a long connection. A server and a client establish a long connection communication. The heartbeat interval processing method is applied to the client, and the method comprises:
[0008] determining a device resource pressure indicator;
[0009] dynamically calculating a target heartbeat interval based on the device resource pressure indicator and a network quality index sent by the server in real time.
[0010] In some possible implementation manners, the determination of the device resource pressure indicator comprises:
[0011] obtaining a device remaining power and a CPU load;
[0012] obtaining the device resource pressure indicator based on the device remaining power and the CPU load.
[0013] In some possible implementation manners, the obtaining of the device resource pressure indicator based on the device remaining power and the CPU load comprises:
[0014] obtaining a target power value based on the device remaining power and a first preset value;
[0015] obtaining a target load value based on the CPU load and a second preset value;
[0016] summing the target electric quantity value and the target load value to obtain the device resource pressure index, wherein the sum of the first preset value and the second preset value is 1.
[0017] In some possible implementation manners, before the dynamic calculation of the target heartbeat interval based on the device resource pressure index and the network quality index sent in real time by the server, the method further includes:
[0018] obtaining a preset basic heartbeat interval;
[0019] The dynamic calculation of the target heartbeat interval based on the device resource pressure index and the network quality index sent in real time by the server includes:
[0020] dynamically calculating a target heartbeat interval based on the preset basic heartbeat interval, the device resource pressure index and the network quality index.
[0021] In some possible implementation manners, the dynamic calculation of the target heartbeat interval based on the preset basic heartbeat interval, the device resource pressure index and the network quality index includes:
[0022] obtaining a target resource pressure value based on the device resource pressure index and a preset first weight coefficient;
[0023] obtaining a target network quality value based on the network quality index and a preset second weight coefficient;
[0024] performing summation operation on the device resource pressure value, the network quality value and a preset value to obtain a total value;
[0025] performing product operation on the total value and the preset basic heartbeat interval to obtain the target heartbeat interval.
[0026] In some possible implementation manners, the server and the client establish long connection communication, and the heartbeat interval processing method is applied to the server, and the method includes:
[0027] receiving a heartbeat packet sent by the client;
[0028] performing network quality prediction based on the heartbeat packet by using a trained network prediction model to obtain a network quality index;
[0029] sending the network quality index to the client, so that the client dynamically calculates a target heartbeat interval based on a device resource pressure index and the network quality index.
[0030] In some possible implementation manners, the heartbeat packet includes a base station identifier, a signal strength, a time period, a round-trip time variance and a packet loss rate.
[0031] The network quality prediction based on the heartbeat packet by using the trained network prediction model obtains a network quality index, including:
[0032] The base station identifier, the signal strength, the time period, the round-trip time variance and the packet loss rate are input into a trained network prediction model.
[0033] The network quality prediction based on the base station identifier, the signal strength, the time period, the round-trip time variance and the packet loss rate by using the trained network prediction model obtains a network quality index.
[0034] In some possible implementation manners, the network prediction model includes, during training:
[0035] It is judged whether the prediction result of the network quality index is located in a preset range or not.
[0036] If the prediction result of the network quality index is not located in the preset range, the network prediction model is retrained after adjusting parameters.
[0037] In a second aspect, the embodiments of the present application further provide a heartbeat interval processing system based on a long connection, which comprises a client and a server. The client comprises a first processor, a first memory and a first communication module. The first memory is used to store a computer program. The computer program is used to implement the above method when executed by the first processor. The server comprises a second processor, a second memory and a second communication module. The first communication module is in communication connection with the second communication module. The second memory is used to store a computer program. The computer program is used to implement the above method when executed by the second processor.
[0038] In a third aspect, the embodiments of the present application further provide a computer readable storage medium. The storage medium stores a computer program. The computer program can implement the method of any one of the above aspects when executed by a processor.
[0039] The embodiments of the present application provide a heartbeat interval processing method and system based on a long connection and a storage medium. The method comprises determining a device resource pressure indicator and dynamically calculating a target heartbeat interval based on the device resource pressure indicator and a network quality index sent by a server in real time.
[0040] The embodiments of the present application can dynamically perceive the current running state (such as CPU usage, remaining power, etc.) of the device and the quality of the network environment by introducing the network quality index and the device resource pressure index detected in real time. On this basis, the heartbeat sending interval that is adapted to the current situation is intelligently calculated by comprehensively considering the device resource status and the network communication state in two dimensions. For example, in the case that the device resource is relatively relaxed and the network quality is good, the system can automatically prolong the heartbeat interval, thereby reducing unnecessary communication behavior and the number of device wake-up times, and effectively reducing energy consumption; when the network state is unstable or the delay is significantly increased, the heartbeat interval is actively shortened to avoid the connection interruption problem caused by timeout disconnection, thereby improving the stability of the long connection between the client and the server. BRIEF DESCRIPTION OF DRAWINGS
[0041] The accompanying drawings, which are incorporated herein and constitute part of the specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or the prior art description will be briefly introduced. Obviously, for those skilled in the art, other drawings can also be obtained based on these drawings without creative labor.
[0043] One or more embodiments are exemplarily illustrated by the pictures in the drawings corresponding thereto, and these exemplary illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, unless otherwise specified. The drawings in the drawings do not constitute a proportional limitation.
[0044] Figure 1 A flowchart of a first embodiment of a heartbeat interval processing method based on a long connection provided by the present application;
[0045] Figure 2 A structure interaction diagram of a heartbeat interval processing system based on a long connection provided by the embodiments of the present application;
[0046] Figure 3 A structure diagram of a client embodiment provided by the present application;
[0047] Figure 4 A structure diagram of a server embodiment provided by the present application. DETAILED DESCRIPTION
[0048] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0049] The following disclosure provides numerous different embodiments or examples for implementing various structures of this application. To simplify the disclosure, specific examples of components and arrangements are described below. These are merely examples and are not intended to limit the scope of this application. Furthermore, reference numerals and / or letters may be repeated in different examples. Such repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed.
[0050] It should be understood that, when used in this specification and the appended claims, the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0051] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of the application. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0052] It should also be further understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0053] As used in this specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrases "if determined" or "if [described condition or event] is detected" may be interpreted, depending on the context, as "once determined," "in response to determination," "once [described condition or event] is detected," or "in response to detection of [described condition or event]."
[0054] Traditional long-connection communication mechanisms typically use a fixed heartbeat interval to maintain the connection state between the client and the server. However, this method has the following problems:
[0055] 1. Regardless of the network environment or device load, the heartbeat packet is sent at the same frequency, causing unnecessary power consumption;
[0056] 2. In the case of poor network quality, high-frequency heartbeat is still maintained, which can easily lead to unstable connection or even disconnection.
[0057] To solve the above problems, the application provides a heartbeat interval processing method based on long connection, which can comprehensively consider the two dimensions of device resource status and network communication state, intelligently calculate the heartbeat interval that adapts to the current situation, reduce unnecessary communication behavior and device wake-up times, effectively reduce energy consumption, and avoid connection interruption caused by timeout disconnection, thereby improving the stability of long connection between the client and the server.
[0058] Referring to Figure 1 , Figure 1 The flowchart of a first embodiment of a heartbeat interval processing method based on long connection provided by the application, wherein the server and the client establish long connection communication, the heartbeat interval processing method is applied to the client, and the method comprises the following steps:
[0059] Step 110: Determine the device resource pressure index.
[0060] Step 120: Based on the device resource pressure index and the network quality index sent by the server in real time, dynamically calculate the target heartbeat interval.
[0061] For example, if the device resource pressure index is P1 and the network quality index is Q1, the calculated target heartbeat interval is T1, if the device resource pressure index is P2 and the network quality index is Q2, the calculated target heartbeat interval is T2, if the device resource pressure index is P3 and the network quality index is Q3, the calculated target heartbeat interval is T3.
[0062] The embodiment of the application introduces the real-time detected network quality index and device resource pressure index, which can dynamically perceive the current running state of the device (such as CPU usage, remaining power, etc.) and the quality of the network environment. On this basis, the two dimensions of device resource status and network communication state are considered, and the heartbeat sending interval that adapts to the current situation is intelligently calculated. For example, in the case of relatively relaxed device resources and good network quality, the system can automatically prolong the heartbeat interval, thereby reducing unnecessary communication behavior and device wake-up times, effectively reducing energy consumption; when the network state is unstable or the delay is significantly increased, the heartbeat interval is actively shortened to avoid connection interruption caused by timeout disconnection, thereby improving the stability of long connection between the client and the server.
[0063] Referring to a second embodiment of a heartbeat interval processing method based on a long connection provided by the present application, a service end and a client establish long connection communication, the heartbeat interval processing method is applied to the client, and the method comprises the following steps:
[0064] Step 210: Obtain a device remaining power and a CPU load.
[0065] Step 220: Obtain a device resource pressure index based on the device remaining power and the CPU load.
[0066] In some possible embodiments, step 220 can comprise the following:
[0067] Step 221: Obtain a target power value based on the device remaining power and a first preset value.
[0068] Step 222: Obtain a target load value based on the CPU load and a second preset value.
[0069] Step 223: Perform summation operation on the target power value and the target load value to obtain the device resource pressure index.
[0070] Wherein, the sum of the first preset value and the second preset value is 1.
[0071] For steps 221-223, the calculation of the device resource pressure index can refer to the following formula 1:
[0072] P = 0.6 * L + 0.4 * B -1 , formula 1.
[0073] Wherein, P is the device resource pressure index, L is the CPU load, B is the device remaining power, 0.4 is the first preset value, 0.6 is the second preset value, 0.4 * B -1 is the target power value, and 0.6 * L is the target load value.
[0074] In other embodiments, the first preset value can be 0.3, the second preset value can be 0.7, etc., and the specific values of the first preset value and the second preset value can be set and adjusted according to actual scenes, which are not limited in the present application.
[0075] Step 230: Dynamically calculate a target heartbeat interval based on the device resource pressure index and a network quality index sent by the service end in real time.
[0076] In some possible implementation manners, before the dynamically calculating the target heartbeat interval based on the device resource pressure indicator and the network quality index sent by the server in real time, the method further includes: obtaining a preset basic heartbeat interval. For details, refer to a third embodiment of a heartbeat interval processing method based on a long connection provided in the present application. The heartbeat interval processing method is applied to a client. The method includes the following steps:
[0077] Step 310: determining a device resource pressure indicator.
[0078] Step 320: dynamically calculating a target heartbeat interval based on the preset basic heartbeat interval, the device resource pressure indicator and the network quality index.
[0079] In some possible implementation manners, the dynamically calculating the target heartbeat interval based on the preset basic heartbeat interval, the device resource pressure indicator and the network quality index includes:
[0080] Step 321: obtaining a target resource pressure value based on the device resource pressure indicator and a preset first weight coefficient.
[0081] Step 322: obtaining a target network quality value based on the network quality index and a preset second weight coefficient.
[0082] Step 323: performing summation operation on the device resource pressure value, the network quality value and a preset value to obtain a total value.
[0083] Step 324: performing product operation on the total value and the preset basic heartbeat interval to obtain the target heartbeat interval.
[0084] Exemplarily, for steps 321-324, refer to the following formula 2 for details:
[0085] T=T0x(1+α*P+β*(1-Q)), formula 2.
[0086] Wherein, T is the target heartbeat interval, the target heartbeat interval T can be at least 30 seconds, the target heartbeat interval T can be at least 290 seconds, T0 is the preset basic heartbeat interval, which can be 60 seconds for example, P is the device resource pressure indicator, α is the preset first weight coefficient, α*P is the target resource pressure value, Q is the network quality index, β is the preset second weight coefficient, and β*(1-Q) is the target network quality value.
[0087] Wherein, the device resource pressure indicator P ∈ [0, 1], P = 0 represents low load, and P = 1 represents high load.
[0088] A network quality index Q, wherein Q=0 represents extremely poor network quality, and Q=1 represents extremely good network quality.
[0089] In some possible embodiments, α=0.5 and β=0.8, or α=0.6 and β=0.7, or the like can be set, and the specific values of the preset first weight coefficient α and the preset second weight coefficient β can be set and adjusted according to actual scenarios, which are not limited herein.
[0090] Referring to a fourth embodiment of the heartbeat interval processing method provided herein, a long connection communication is established between a server and a client, and the heartbeat interval processing method is applied to the server, and the method comprises the following steps:
[0091] Step 410: receiving a heartbeat packet sent by the client.
[0092] Step 420: predicting network quality based on the heartbeat packet by using a trained network prediction model to obtain a network quality index.
[0093] In some possible embodiments, the heartbeat packet comprises a base station identifier (i.e., base station ID), a signal strength, a time period, a round-trip time variance (i.e., RTT variance), and a packet loss rate.
[0094] The network quality prediction based on the heartbeat packet by using the trained network prediction model to obtain the network quality index comprises the following steps:
[0095] Step 421: inputting the base station identifier, the signal strength, the time period, the round-trip time variance, and the packet loss rate into the trained network prediction model.
[0096] Step 422: predicting network quality based on the base station identifier, the signal strength, the time period, the round-trip time variance (i.e., RTT variance), and the packet loss rate by using the trained network prediction model to obtain a network quality index.
[0097] In some possible embodiments, the network quality index can be calculated by using the following formula 3:
[0098] Q=1 / (1+RTT variance+10*packet loss rate), formula 3.
[0099] Wherein, Q is the network quality index.
[0100] Step 430: sending the network quality index to the client, so that the client dynamically calculates a target heartbeat interval based on a device resource pressure indicator and the network quality index.
[0101] Referring to Figure 2In combination with the above embodiments, the heartbeat interval processing method based on the long connection provided in the application mainly includes the following steps:
[0102] Step 11: The client 120 and the server 130 establish a long connection.
[0103] Step 12: The client 120 sends a heartbeat packet to the server 130, wherein the heartbeat contains base station information and network signal strength information, such as base station identification, signal strength, time period, round-trip time variance, and packet loss rate.
[0104] Step 13: The server 130 uses the trained network prediction model to predict the network quality index of a certain base station in a certain time period.
[0105] Step 14: The server 130 issues the network quality index predicted in step 13 to the client 120.
[0106] Step 15: The client 120 dynamically calculates the heartbeat interval that should be set, i.e., the target heartbeat interval, in combination with the network quality index and the locally calculated device resource pressure indicator.
[0107] In some possible implementations, the network prediction model can be an LSTM time series model.
[0108] In some possible implementations, the training of the LSTM time series model can include the following:
[0109] 1. Data collection: The server collects information such as base station identification, signal strength, time period, RTT, packet loss rate, etc.
[0110] 2. Model training: Use machine learning algorithms to train the collected data to build a user behavior prediction model, i.e., an LSTM time series model.
[0111] Specifically, the base station ID, signal strength, time period, RTT variance, and packet loss rate can be input into the LSTM time series model, and the LSTM time series model can be used to predict network quality based on the base station ID, signal strength, time period, RTT variance, and packet loss rate, and output the prediction result of the network quality index.
[0112] Since pytorch has an LSTM built-in, the LSTM time series model training can be directly performed using the pytorch tool.
[0113] For example, the data set can be divided into a training set (90%) and a test set (10%), the LSTM time series model is trained using the training set, and after the training is completed, the test set is used for verification.
[0114] In some possible implementation manners, when the network prediction model is trained, the network prediction model can include determining whether the predicted result of the network quality index is within a preset range, for example, the predicted result of the network quality index is within a range of -30% to 30% of a preset expected value, and the training is considered successful.
[0115] If the predicted result of the network quality index is not within the preset range, the parameters of the network prediction model are adjusted and the network prediction model is retrained.
[0116] For example, the predicted result of the network quality index is 50% different from the preset expected value, and the accuracy deviation is considered too large. Based on this, the parameters of the LSTM time series model are adjusted and the LSTM time series model is retrained until the predicted result of the network quality index is within the preset range.
[0117] The parameters of the LSTM time series model can include, but are not limited to, the dimension of a hidden layer, the number of LSTM layers, a learning rate, and the like.
[0118] In some possible implementation manners, when the parameters of the LSTM time series model are adjusted, only one of the parameters can be adjusted and the LSTM time series model is retrained.
[0119] In addition, new data can be added to the data training set to optimize the LSTM time series model, thereby improving the prediction accuracy of the LSTM time series model.
[0120] Corresponding to the above method for processing a heartbeat interval based on a long connection, the application further provides a device for processing a heartbeat interval based on a long connection. The device for processing a heartbeat interval based on a long connection includes units for executing the above method for processing a heartbeat interval based on a long connection, and the device for processing a heartbeat interval based on a long connection can be configured in a desktop computer, a tablet computer, a laptop computer, or the like.
[0121] Corresponding to the above method for processing a heartbeat interval based on a long connection, the application further provides a system for processing a heartbeat interval based on a long connection. The system for processing a heartbeat interval based on a long connection includes a client and a server. The client includes a first processor, a first memory, and a first communication module. The first memory is configured to store a computer program. The computer program is configured to be executed by the first processor to implement the method in the above embodiments. The server includes a second processor, a second memory, and a second communication module. The first communication module is in communication connection with the second communication module. The second memory is configured to store a computer program. The computer program is configured to be executed by the second processor to implement the method in the above embodiments.
[0122] Specifically, refer to Figure 3 , Figure 3is a structural schematic diagram of an embodiment of a client provided by the present application. The client 120 comprises a first processor 121, a first memory 122 and a first communication module 123, the first memory 122 is used for storing a computer program, the computer program is executed by the first processor 121, and is used for implementing the following method:
[0123] determining a device resource pressure index;
[0124] dynamically calculating a target heartbeat interval based on the device resource pressure index and a network quality index sent in real time by a server.
[0125] In some embodiments, the determining of the device resource pressure index comprises:
[0126] obtaining a device remaining power and a CPU load;
[0127] obtaining the device resource pressure index based on the device remaining power and the CPU load.
[0128] In some embodiments, the obtaining of the device resource pressure index based on the device remaining power and the CPU load comprises:
[0129] obtaining a target power value based on the device remaining power and a first preset value;
[0130] obtaining a target load value based on the CPU load and a second preset value;
[0131] performing summation operation on the target power value and the target load value to obtain the device resource pressure index, wherein a sum of the first preset value and the second preset value is 1.
[0132] In some embodiments, before the dynamically calculating of the target heartbeat interval based on the device resource pressure index and the network quality index sent in real time by the server, the method further comprises:
[0133] obtaining a preset basic heartbeat interval;
[0134] The dynamically calculating of the target heartbeat interval based on the device resource pressure index and the network quality index sent in real time by the server comprises:
[0135] dynamically calculating the target heartbeat interval based on the preset basic heartbeat interval, the device resource pressure index and the network quality index.
[0136] In some embodiments, the dynamically calculating of the target heartbeat interval based on the preset basic heartbeat interval, the device resource pressure index and the network quality index comprises:
[0137] obtain a target resource pressure value based on the device resource pressure indicator and a preset first weight coefficient;
[0138] obtain a target network quality value based on the network quality indicator and a preset second weight coefficient;
[0139] perform summation operation on the device resource pressure value, the network quality value and a preset value to obtain a total value;
[0140] perform product operation on the total value and the preset basic heartbeat interval to obtain the target heartbeat interval.
[0141] Referring to Figure 4 , Figure 4 is a structural schematic diagram of an embodiment of a server provided by the present application. The server 130 comprises a second processor 131, a second memory 132 and a second communication module 133. The second memory 132 is configured to store a computer program. When the computer program is executed by the second processor 131, the computer program is configured to implement the following method:
[0142] receive a heartbeat packet sent by a client;
[0143] perform network quality prediction based on the heartbeat packet by using a trained network prediction model to obtain a network quality indicator;
[0144] send the network quality indicator to the client, so that the client dynamically calculates a target heartbeat interval based on a device resource pressure indicator and the network quality indicator.
[0145] In some embodiments, the heartbeat packet comprises a base station identifier, a signal strength, a time period, a round-trip time variance and a packet loss rate.
[0146] The network quality prediction based on the heartbeat packet by using the trained network prediction model to obtain the network quality indicator comprises:
[0147] input the base station identifier, the signal strength, the time period, the round-trip time variance and the packet loss rate into the trained network prediction model;
[0148] perform network quality prediction based on the base station identifier, the signal strength, the time period, the round-trip time variance and the packet loss rate by using the trained network prediction model to obtain the network quality indicator.
[0149] Those skilled in the art can understand that all or part of the processes in the method of the above embodiments can be completed by instructing the relevant hardware by a computer program. The computer program can be stored in a storage medium, which is a computer readable storage medium. The computer program is executed by at least one processor in the computer system to realize the process steps of the above method embodiments.
[0150] Therefore, the embodiments of the present application also provide a computer readable storage medium, which stores a computer program. The computer program is executed by a processor to realize the steps of the long connection-based heartbeat interval processing method provided by any one of the above method embodiments, including:
[0151] Determining a device resource pressure index;
[0152] Based on the device resource pressure index and the network quality index sent by the server in real time, dynamically calculating a target heartbeat interval.
[0153] The storage medium is an entity, non-transient storage medium, for example, can be a U disk, a mobile hard disk, a read-only memory (Read-Only Memory, ROM), a magnetic disk or an optical disk, and various entity storage media that can store program codes. The computer readable storage medium can be non-volatile or volatile.
[0154] Those skilled in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized by electronic hardware, computer software or a combination of both. In order to clearly illustrate the interchangeability of hardware and software, the components and steps of each example have been described in the above description in general terms. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0155] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of each unit is only a logical function division, and actual implementation can have another division manner. For example, a plurality of units or components can be combined or integrated into another system, or some features can be omitted or not executed.
[0156] The steps in the method embodiments of the present application can be adjusted in sequence, combined and deleted according to actual needs. The units in the device embodiments of the present application can be combined, divided and deleted according to actual needs. In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit.
[0157] The integrated unit, if realized in the form of a software functional unit and sold or used as an independent product, can be stored in a storage medium. Based on such understanding, the technical solutions of the present application essentially or say the part that contributes to the prior art, or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, a terminal or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.
[0158] In the above embodiments, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.
[0159] Obviously, those skilled in the art can make various modifications and variations to the present application without departing from the spirit and scope of the present application. Thus, these modifications and variations of the present application are intended to be included within the scope of the claims of the present application and their equivalents. Therefore, the present application is also intended to include these modifications and variations.
[0160] The above is merely specific implementation of the present application, but the protection scope of the present application is not limited to this. Any skilled person in the art can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A method for processing heartbeat intervals based on long connections, characterized in that, The server and client establish a long-lived connection for communication. The heartbeat interval processing method is applied to the client, and the method includes: Determine equipment resource pressure indicators; The target heartbeat interval is dynamically calculated based on the device resource pressure index and the network quality index sent in real time by the server.
2. The method according to claim 1, characterized in that, The determination of equipment resource pressure indicators includes: Obtain the device's remaining battery power and CPU load; Based on the remaining power of the device and the CPU load, the resource pressure index of the device is obtained.
3. The method according to claim 2, characterized in that, The process of obtaining the device resource pressure index based on the device's remaining power and CPU load includes: Based on the remaining battery power of the device and a first preset value, the target battery power value is obtained; Based on the CPU load and the second preset value, the target load value is obtained; The target power value and the target load value are summed to obtain the equipment resource pressure index, wherein the sum of the first preset value and the second preset value is 1.
4. The method according to claim 1, characterized in that, Before dynamically calculating the target heartbeat interval based on the device resource pressure index and the network quality index sent in real time by the server, the method further includes: Obtain the preset baseline heart rate interval; The dynamic calculation of the target heartbeat interval based on the device resource pressure index and the network quality index sent in real time by the server includes: The target heartbeat interval is dynamically calculated based on the preset basic heartbeat interval, the device resource pressure index, and the network quality index.
5. The method according to claim 4, characterized in that, The dynamic calculation of the target heartbeat interval based on the preset basic heartbeat interval, the device resource pressure index, and the network quality index includes: Based on the equipment resource pressure index and the preset first weighting coefficient, the target resource pressure value is obtained; The target network quality value is obtained based on the network quality index and the preset second weighting coefficient. The total value is obtained by summing the device resource pressure value, the network quality value, and the preset value. The target heart rate interval is obtained by multiplying the total value with the preset base heart rate interval.
6. A method for processing heartbeat intervals based on long connections, characterized in that, The server and client establish a long-lived connection for communication. The heartbeat interval processing method is applied to the server, and the method includes: Receive heartbeat packets sent by the client; The network quality index is obtained by using the trained network prediction model based on the heartbeat packets to predict network quality. The network quality index is sent to the client so that the client can dynamically calculate the target heartbeat interval based on the device resource pressure index and the network quality index.
7. The method according to claim 6, characterized in that, The heartbeat packet includes base station identifier, signal strength, time period, round-trip time variance, and packet loss rate; The process of using a trained network prediction model to predict network quality based on the heartbeat packets, and obtaining a network quality index, includes: Input the base station identifier, the signal strength, the time period, the round-trip time variance, and the packet loss rate into the trained network prediction model; The network quality index is obtained by using the trained network prediction model based on the base station identifier, the signal strength, the time period, the round-trip time variance, and the packet loss rate to predict network quality.
8. The method according to claim 6, characterized in that, The network prediction model, during training, includes: Determine whether the predicted result of the network quality index is within a preset range; If the predicted result of the network quality index is not within the preset range, the parameters of the network prediction model will be adjusted and the model will be retrained.
9. A heartbeat interval processing system based on long-connection communication, characterized in that, The heartbeat interval processing system includes a client and a server. The client includes a first processor, a first memory, and a first communication module. The first memory stores a computer program. When the computer program is executed by the first processor, it is used to implement the heartbeat interval processing method as described in any one of claims 1-5. The server includes a second processor, a second memory, and a second communication module. The first communication module is communicatively connected to the second communication module. The second memory stores a computer program. When the computer program is executed by the second processor, it is used to implement the heartbeat interval processing method as described in any one of claims 6-8.
10. A computer-readable storage medium, characterized in that, The storage medium stores a computer program that, when executed by a processor, can implement the method as described in any one of claims 1-8.