Intelligent heartbeat keep-alive method and device, terminal and storage medium

By monitoring the data transmission status of edge gateways and cloud servers, heartbeat packets are only sent when there is no service data transmission, and heartbeat intervals are dynamically adjusted, the bandwidth waste and network congestion caused by traditional heartbeat mechanisms are solved, and efficient data transmission and resource utilization are achieved.

CN120281809APending Publication Date: 2025-07-08SHENZHEN PAPA SPORTS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510548474.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-28
Publication Date
2025-07-08

AI Technical Summary

Technical Problem

The traditional heartbeat mechanism sends heartbeat packets regardless of whether there is service data transmission, resulting in bandwidth occupation and waste, especially in the case of high channel load, which aggravates network congestion.

Method used

By monitoring the data transmission status between the edge gateway and the cloud server, the heartbeat packet is only sent when there is no service data transmission, and the heartbeat interval is dynamically adjusted based on the sending situation and content of the heartbeat packet, and the heartbeat interval is optimized to adapt to network status and communication load.

Benefits of technology

Reduce bandwidth waste, avoid network congestion caused by heartbeat packets competing for bandwidth with service data, ensure efficient transmission of control instructions and service data, and improve system stability and resource utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120281809A_ABST
    Figure CN120281809A_ABST
Patent Text Reader

Abstract

The invention provides an intelligent heartbeat keep-alive method and device, a terminal and a storage medium, and belongs to the technical field of communication, and the method comprises the steps: after an edge gateway and a cloud server establish TCP connection, initializing a heartbeat interval, and monitoring a data transmission state between the edge gateway and the cloud server; if the data transmission state is that no service data transmission exists, controlling the edge gateway to send a heartbeat packet to a cloud server at a heartbeat interval; adjusting a corresponding heartbeat interval based on the sending condition of the heartbeat packet and the content of the heartbeat packet; and after the heartbeat interval is adjusted each time, if the data transmission state is that service data transmission does not exist, controlling the edge gateway to send a heartbeat packet to a cloud server at the adjusted heartbeat interval. According to the invention, the heartbeat packet is sent only when no service data is transmitted, and the heartbeat interval is dynamically adjusted based on the sending condition of the heartbeat packet and the content of the heartbeat packet, so that the defects of bandwidth occupation and bandwidth waste of a traditional static heartbeat mechanism are overcome.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication technologies, and particularly to an intelligent heartbeat keep-alive method, device, terminal, and storage medium. Background Art

[0002] The traditional heartbeat mechanism sends heartbeat packets at predefined fixed time intervals. This static strategy causes heartbeat packets to be sent regardless of whether there is business data transmission. In the case of high channel load, the heartbeat packets compete with business data for bandwidth, exacerbating network congestion. In addition, the business data packets themselves already contain implicit connection activity information. At this time, the repeated detection of heartbeat packet data causes bandwidth waste.

[0003] Therefore, the prior art has defects and needs to be improved and developed. Summary of the Invention

[0004] The technical problem to be solved by the present invention is to provide an intelligent heartbeat keep-alive method, device, terminal, and storage medium for the above-mentioned defects of the prior art, aiming to solve the problems of bandwidth occupation and bandwidth waste caused by sending heartbeat packets without distinguishing the data transmission status in the prior art.

[0005] The technical solution adopted by the present invention to solve the technical problem is as follows:

[0006] In a first aspect, an embodiment of the present invention provides an intelligent heartbeat keep-alive method, and the method includes:

[0007] After a TCP connection is established between the edge gateway and the cloud server, initialize the heartbeat interval and monitor the data transmission status between the edge gateway and the cloud server;

[0008] If the data transmission status is that there is no business data transmission, control the edge gateway to send a heartbeat packet to the cloud server at the heartbeat interval;

[0009] Adjust the corresponding heartbeat interval based on the sending situation and content of the heartbeat packet;

[0010] After each adjustment of the heartbeat interval, if the data transmission status is that there is no business data transmission, control the edge gateway to send a heartbeat packet to the cloud server at the adjusted heartbeat interval.

[0011] In an implementation manner, adjusting the corresponding heartbeat interval based on the sending situation and content of the heartbeat packet includes:

[0012] Determine the network status according to the sending situation of the heartbeat packet;

[0013] Determine the communication load status according to the content of the heartbeat packet;

[0014] When the network status is network fluctuation, shorten the corresponding heartbeat interval to a first preset value to obtain an adjusted heartbeat interval;

[0015] When the network status is network stability, extend the corresponding heartbeat interval in combination with the communication load status to obtain an adjusted heartbeat interval.

[0016] In one implementation, determining the network status according to the sending situation of heartbeat packets includes:

[0017] If the network delay of each heartbeat packet is greater than a first preset delay threshold or the jitter value of each heartbeat packet is greater than a first preset jitter threshold when sending heartbeat packets for a first preset number of times, determine that the network status is network fluctuation;

[0018] If the network delay of each heartbeat packet is less than a second preset delay threshold and the jitter value of each heartbeat packet is lower than a second preset jitter threshold when sending heartbeat packets for a second preset number of times, determine that the network status is network stability.

[0019] In one implementation, determining the communication load status according to the content of the heartbeat packet includes:

[0020] If the control instruction frequency in the heartbeat packet is lower than a preset control instruction frequency and the data acquisition frequency is lower than a preset data acquisition frequency, determine that the communication load status is low load;

[0021] If the control instruction frequency in the heartbeat packet is higher than a preset control instruction frequency or the data acquisition frequency is higher than a preset data acquisition frequency, determine that the communication load status is high load.

[0022] In one implementation, when the network status is network stability, extending the corresponding heartbeat interval in combination with the communication load status to obtain an adjusted heartbeat interval includes:

[0023] When the network status is network stability and the communication load status is high load, extend the corresponding heartbeat interval to a second preset value and multiply the second preset value by a preset ratio to obtain an adjusted heartbeat interval;

[0024] When the network status is network stability and the communication load status is low load, extend the corresponding heartbeat interval to a second preset value to obtain an adjusted heartbeat interval.

[0025] In one implementation, the method further includes: if the data transmission status is that there is business data transmission, suspend the sending of heartbeat packets.

[0026] In one embodiment, the method further includes: if the edge gateway does not receive a heartbeat response within a time threshold after sending a heartbeat packet, determining that the TCP connection is interrupted, and performing a TCP reconnection operation between the edge gateway and the cloud server.

[0027] In a second aspect, an embodiment of the present invention further provides an intelligent heartbeat keep-alive device, which includes:

[0028] A monitoring module, configured to initialize a heartbeat interval after a TCP connection is established between the edge gateway and the cloud server, and monitor the data transmission status between the edge gateway and the cloud server;

[0029] An edge gateway first heartbeat sending module, configured to control the edge gateway to send a heartbeat packet to the cloud server at the heartbeat interval if the data transmission status is that there is no service data transmission;

[0030] An interval adjustment module, configured to adjust the corresponding heartbeat interval based on the sending situation of the heartbeat packet and the content of the heartbeat packet;

[0031] A second heartbeat sending module, configured to control the edge gateway to send a heartbeat packet to the cloud server at the adjusted heartbeat interval if the data transmission status is that there is no service data transmission after each adjustment of the heartbeat interval.

[0032] In a third aspect, an embodiment of the present invention further provides a terminal, which includes: a memory, a processor, and an intelligent heartbeat keep-alive program stored on the memory and executable on the processor, and when the intelligent heartbeat keep-alive program is executed by the processor, the steps of the intelligent heartbeat keep-alive method described above are implemented.

[0033] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, which stores an intelligent heartbeat keep-alive program, and the intelligent heartbeat keep-alive program can be executed to implement the steps of the intelligent heartbeat keep-alive method described above.

[0034] Advantages of the present invention: After the edge gateway and the cloud server establish a TCP connection, the present invention initializes the heartbeat interval and monitors the data transmission status between the edge gateway and the cloud server; if there is no business data transmission in the data transmission status, it controls the edge gateway to send a heartbeat packet to the cloud server at the heartbeat interval; adjusts the corresponding heartbeat interval based on the sending situation and content of the heartbeat packet; after each adjustment of the heartbeat interval, if there is no business data transmission in the data transmission status, it controls the edge gateway to send a heartbeat packet to the cloud server at the adjusted heartbeat interval. By only sending heartbeat packets when there is no business data transmission and dynamically adjusting the heartbeat interval based on the sending situation and content of the heartbeat packet, the present invention solves the defects of occupying bandwidth and wasting bandwidth in the traditional static heartbeat mechanism. Description of the Drawings

[0035] Figure 1 is a flowchart of a preferred embodiment of the intelligent heartbeat keep-alive method in the present invention.

[0036] Figure 2 is a flowchart of the heartbeat interval adjustment in the present invention.

[0037] Figure 3 is a flowchart of pausing heartbeat sending in the present invention.

[0038] Figure 4 is a flowchart of sample heartbeat packet sending.

[0039] Figure 5 is a schematic structural diagram of a preferred embodiment of the intelligent heartbeat keep-alive device in the present invention.

[0040] Figure 6 is a principle block diagram of the terminal in the present invention. Detailed Embodiments

[0041] To make the objectives, technical solutions and advantages of the present invention clearer and more explicit, the following further describes the present invention in detail with reference to the accompanying drawings and by way of examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0042] The traditional heartbeat mechanism sends heartbeat packets at a predefined fixed time interval. This static strategy results in sending heartbeats regardless of whether there is business data transmission. In the case of high channel load, the heartbeat packets compete with business data for bandwidth, exacerbating network congestion. In addition, the business data packets themselves already contain connection activity information, and at this time, the heartbeat packet data is repeatedly detected, causing bandwidth waste.

[0043] In view of the above defects of the prior art, the present invention provides an intelligent heartbeat keep-alive method, device, terminal and storage medium. The method includes: after the edge gateway and the cloud server establish a TCP connection, initializing a heartbeat interval and monitoring the data transmission status between the edge gateway and the cloud server; if the data transmission status is that there is no business data transmission, controlling the edge gateway to send a heartbeat packet to the cloud server at the heartbeat interval; adjusting the corresponding heartbeat interval based on the sending situation and content of the heartbeat packet; after each adjustment of the heartbeat interval, if the data transmission status is that there is no business data transmission, controlling the edge gateway to send a heartbeat packet to the cloud server at the adjusted heartbeat interval. The present invention solves the defects of bandwidth occupation and bandwidth waste of the traditional static heartbeat mechanism by sending heartbeat packets only when there is no business data transmission and dynamically adjusting the heartbeat interval based on the sending situation and content of the heartbeat packet.

[0044] Please refer to Figure 1 , the intelligent heartbeat keep-alive method described in the embodiment of the present invention includes the following steps:

[0045] Step S100, after the edge gateway and the cloud server establish a TCP connection, initialize a heartbeat interval and monitor the data transmission status between the edge gateway and the cloud server.

[0046] Specifically, the intelligent heartbeat keep-alive method of the present invention is applied to the edge gateway and the cloud server. In the present invention, multiple terminal devices are connected to the edge gateway, and the data of the terminal devices needs to be uploaded to the cloud server through the edge gateway. In addition, the control instructions of the cloud server are transmitted to the terminal devices through the edge gateway. The edge gateway and the cloud server are connected through the TCP protocol. If there are reasons such as network fluctuations, no data transmission for a long time, or server resource limitations, the TCP connection may be interrupted. In this case, the control instructions of the cloud server cannot be sent to the terminal devices, which will affect the real-time control of the terminal devices, and the data of the terminal devices cannot be uploaded in time, which may cause data loss or delay. It is necessary to set up a heartbeat mechanism to monitor the TCP connection status of the edge gateway and the cloud server. In the present invention, after the edge gateway and the cloud server establish a TCP connection, a heartbeat interval is set and the heartbeat timer in the edge gateway is started. The heartbeat interval can be 5 seconds per time. And the data transmission status between the edge gateway and the cloud server is monitored in real time, and then it is judged whether a heartbeat packet needs to be sent according to different data transmission statuses.

[0047] In one implementation, the terminal device is an Internet of Things device.

[0048] Specifically, the Internet of Things device in the present invention can collect data and report it to the cloud server through the edge gateway, and receive the control instructions forwarded by the cloud server through the edge gateway.

[0049] Please refer toFigure 1 , the intelligent heartbeat keep-alive method described in the embodiments of the present invention further includes the following steps:

[0050] Step S200, if the data transmission state is that there is no service data transmission, control the edge gateway to send heartbeat packets to the cloud server at the heartbeat interval.

[0051] Specifically, after the edge gateway and the cloud server establish a TCP connection, if there is no service data transmission between them, it is necessary to send heartbeat packets to maintain the activity of the TCP connection and detect whether the connection is valid. The service data is the control instruction sent by the cloud server to the terminal device or the data collected by the terminal device. When the timer is triggered, if the data transmission state is that there is no service data transmission, control the edge gateway to send heartbeat packets to the cloud server at the heartbeat interval. By only sending heartbeat packets when there is no service data transmission, and when there is service data interaction, using the service data stream to maintain the activity of the TCP connection, the present invention eliminates the problems of instruction delay, data loss, and resource waste caused by the parallel transmission of service data and heartbeat packets in the traditional solution, ensuring the efficient transmission of control instructions and service data.

[0052] Please refer to Figure 1 , the intelligent heartbeat keep-alive method described in the embodiments of the present invention further includes the following steps:

[0053] Step S300, adjust the corresponding heartbeat interval based on the sending situation of the heartbeat packets and the content of the heartbeat packets.

[0054] Specifically, the heartbeat in the present invention includes a gateway identifier, a timestamp, a communication load status, and a network quality index. The gateway identifier is the unique identifier of the edge gateway's identity. The timestamp is the sending time of the heartbeat packet, which is used to calculate the network delay (Round-Trip Time, RTT). The communication load status includes the control instruction frequency (times / second), the data collection frequency (times / second), and the cache queue length (KB). The network quality index includes the historical average delay (RTT) and the effective throughput (KB / s). It can be understood that after adjusting the heartbeat interval, the heartbeat packet will be sent at the adjusted heartbeat interval in the next heartbeat sending cycle.

[0055] In one implementation, adjusting the corresponding heartbeat interval based on the sending situation of the heartbeat packets and the content of the heartbeat packets includes:

[0056] Determine the network state according to the sending situation of the heartbeat packets;

[0057] Determine the communication load status according to the content of the heartbeat packets;

[0058] When the network state is network fluctuation, shorten the corresponding heartbeat interval to a first preset value to obtain the adjusted heartbeat interval;

[0059] When the network state is stable, the corresponding heartbeat interval is extended in combination with the communication load state to obtain an adjusted heartbeat interval.

[0060] Specifically, the present invention perceives the network state by the sending situation of heartbeat packets. When the network state is fluctuating, the heartbeat interval needs to be shortened to quickly determine the TCP connection state and avoid data collection loss or instruction loss caused by connection disconnection. The range of the first preset value is 1 - 2 seconds. When the network state is stable, the communication load state is combined to adjust the heartbeat interval to avoid the heartbeat packet occupying bandwidth or causing resource waste. Through this adaptive method, under the technical constraint of maintaining the reliability of the TCP connection, the balance between network resource utilization and service quality of the service is achieved.

[0061] In one implementation, determining the network state according to the sending situation of heartbeat packets includes:

[0062] If the heartbeat packets are sent for the first preset number of times, and the network delay of each heartbeat packet is greater than the first preset delay threshold, or the jitter value of each heartbeat packet is greater than the first preset jitter threshold, then the network state is determined to be fluctuating;

[0063] If the heartbeat packets are sent for the second preset number of times, and the network delay of each heartbeat packet is less than the second preset delay threshold and the jitter value of each heartbeat packet is lower than the second preset jitter threshold, then the network state is determined to be stable.

[0064] Specifically, after each heartbeat packet is sent to the cloud server, the cloud server calculates the network delay and jitter value based on the received heartbeat packet and returns them to the edge gateway in the form of a heartbeat response packet. The range of the first preset number of times can be 3 - 5 times, the range of the first preset delay threshold can be 150 - 300 ms, and the range of the first preset jitter threshold can be 40 - 80 ms. The range of the second preset number of times can be 8 - 12 times, the range of the second preset delay threshold can be 80 - 120 ms, and the range of the second preset jitter threshold can be 15 - 30 ms.

[0065] In one embodiment, the first preset number of times is 3 times, the first preset delay threshold is 200 ms, and the first preset jitter threshold is 50 ms.

[0066] In one embodiment, the second preset number of times is 10 times, the second preset delay threshold is 100 ms, and the second preset jitter threshold is 20 ms.

[0067] In one embodiment, determining the communication load state according to the heartbeat packet content includes:

[0068] If the control instruction frequency in the heartbeat packet is lower than the preset control instruction frequency and the data acquisition frequency is lower than the preset data acquisition frequency, then determine that the communication load status is low load;

[0069] If the control instruction frequency in the heartbeat packet is higher than the preset control instruction frequency or the data acquisition frequency is higher than the preset data acquisition frequency, then determine that the communication load status is high load.

[0070] Specifically, the range of the preset control instruction frequency is 1 - 3 times per second, and the range of the preset data acquisition frequency is 8 - 12 times per second. Preferably, the preset control instruction frequency is 2 times per second, and the preset data acquisition frequency is 10 times per second. By clearly defining the ranges of the control instruction frequency and the data acquisition frequency, the present invention can clearly define low load and high load. This quantitative standard provides an objective basis for load assessment and data support for subsequent adjustment of the heartbeat interval.

[0071] In one embodiment, when the network status is network stable, then extend the corresponding heartbeat interval in combination with the communication load status to obtain the adjusted heartbeat interval, including:

[0072] When the network status is network stable and the communication load status is high load, then extend the corresponding heartbeat interval to a second preset value, and multiply the second preset value by a preset ratio to obtain the adjusted heartbeat interval;

[0073] When the network status is network stable and the communication load status is low load, then extend the corresponding heartbeat interval to a second preset value to obtain the adjusted heartbeat interval.

[0074] Specifically, when the network status is network stable and the communication load status is high load, then adjust the heartbeat interval in two steps. First, extend the heartbeat interval to a second preset value. The range of the second preset value is 6 - 10 seconds. Then multiply the second preset value by the preset ratio to obtain the adjusted heartbeat interval. The range of the preset ratio is 120% - 150%. In this way, it is possible to avoid frequently sending heartbeat packets in a high load scenario and reduce the risk of aggravating network congestion due to the heartbeat mechanism itself. When the network status is network stable and the communication load status is low load, only extend the heartbeat interval to the second preset value to obtain the adjusted heartbeat interval. In this way, it is possible to maintain the necessary heartbeat frequency in a low load scenario, prevent the connection from being misjudged as invalid due to long - time lack of data interaction, and thus improve the fault tolerance and stability of the system. The flowchart of the heartbeat interval adjustment is as Figure 2 shown.

[0075] Please refer to Figure 1 , the intelligent heartbeat keep - alive method described in the embodiment of the present invention further includes the following steps:

[0076] Step S400: After each adjustment of the heartbeat interval, if the data transmission status indicates no business data transmission, control the edge gateway to send a heartbeat packet to the cloud server at the adjusted heartbeat interval.

[0077] Specifically, the present invention continuously and dynamically adjusts the heartbeat interval so that the heartbeat interval conforms to the network status and communication load status, avoiding waste of resources and reducing the burden on the cloud server.

[0078] In one embodiment, the method further includes: if the data transmission status indicates the existence of business data transmission, suspend the sending of heartbeat packets.

[0079] Specifically, in the present invention, when there is business data transmission (i.e., when there is instruction transmission or business data reporting), the sending of heartbeat packets is suspended. Since the business data transmission also implies the determinable TCP connection status, no heartbeat packet is sent at this time, avoiding waste of resources. In this way, the problems of instruction delay, data loss, and resource waste caused by the parallel transmission of business data and heartbeat packets in the traditional solution can be effectively eliminated, ensuring the efficient transmission of control instructions and business data.

[0080] The flowchart of suspending heartbeat sending can be as Figure 3 shown. It can be understood that when there is no business data transmission after the heartbeat timer is triggered, a heartbeat packet will be sent again, and the dynamic adjustment of the heartbeat interval will continue.

[0081] In one embodiment, the method further includes: if the edge gateway does not receive a heartbeat response within a time threshold after sending a heartbeat packet, determine that the TCP connection is interrupted, and perform a TCP reconnection operation between the edge gateway and the cloud server.

[0082] Specifically, when the edge gateway sends a heartbeat packet to the cloud server, a heartbeat response packet sent by the cloud server is usually received within a preset time. If not received, it is determined that the TCP connection is interrupted. At this time, a TCP reconnection operation is required. The time threshold is twice the current heartbeat interval. The present invention can ensure the effective connection between the edge gateway and the cloud server by triggering the reconnection mechanism (i.e., performing TCP reconnection). It can be understood that after each reconnection of TCP, the heartbeat interval will be re-initialized and the heartbeat timer will be started, and the dynamic adjustment of the heartbeat interval will continue.

[0083] In one implementation, the preset time is 10 seconds.

[0084] In one embodiment, the reconnection mechanism adopts an exponential backoff strategy, and the maximum number of retries is 5 times.

[0085] Specifically, the exponential backoff strategy specifically performs connection retries at 1 second, 2 seconds, 4 seconds, etc. When the number of retries exceeds 5 times and the connection is still not successful, a prompt message is generated to inform the user.

[0086] The schematic diagram of the heartbeat packet sending process of the present invention is as Figure 4 shown. After the edge gateway and the cloud server establish a TCP connection, initialize the heartbeat interval and start the heartbeat timer, and monitor the data transmission status between the edge gateway and the cloud server; when the timer triggers and if the data transmission status is that there is no business data transmission, control the edge gateway to send a heartbeat packet to the cloud server at the heartbeat interval; dynamically adjust the heartbeat interval according to the sending situation of the heartbeat packet and update the timer. When the timer triggers and if the data transmission status is that there is business data transmission, pause the sending of the heartbeat packet. If the heartbeat response packet is not received within the timeout period, trigger the reconnection mechanism. The present invention adjusts the heartbeat interval according to the sending situation of the heartbeat packet, so that the sending strategy of the heartbeat packet is synchronized with the current network state and communication load state. In scenarios of network quality fluctuations or business bursts, it avoids problems such as "over-sending" (when the network is congested) or "detection lag" (when the network is idle) caused by a fixed heartbeat interval, and realizes the dynamic balance between the heartbeat mechanism and the external environment. The present invention only activates the adjusted heartbeat interval when there is no business data transmission, ensuring the absolute priority of the business data channel. By reducing the redundant transmission of unnecessary heartbeat packets, it reduces the computing overhead of the edge gateway (such as data encapsulation, encryption) and the connection management pressure of the cloud server, and can significantly improve the overall system throughput capacity especially in high-concurrency scenarios. The present invention realizes the three-dimensional collaborative optimization of network resources, device performance and business requirements within the technical framework of ensuring the reliability of the TCP connection through a closed-loop feedback mechanism, and is applicable to Internet of Things application scenarios with comprehensive requirements for real-time performance, stability and energy efficiency ratio.

[0087] In one embodiment, as Figure 5 shown, based on the above intelligent heartbeat keep-alive method, the present invention also correspondingly provides an intelligent heartbeat keep-alive device, and the device includes:

[0088] A monitoring module, configured to initialize the heartbeat interval and monitor the data transmission status between the edge gateway and the cloud server after the edge gateway and the cloud server establish a TCP connection;

[0089] A first heartbeat sending module, configured to control the edge gateway to send a heartbeat packet to the cloud server at the heartbeat interval if the data transmission status is that there is no business data transmission;

[0090] An interval adjustment module, configured to adjust the corresponding heartbeat interval based on the sending situation of the heartbeat packet and the content of the heartbeat packet;

[0091] A second heartbeat sending module, configured to, after each adjustment of the heartbeat interval, if the data transmission status is that there is no service data transmission, control the edge gateway to send a heartbeat packet to the cloud server at the adjusted heartbeat interval.

[0092] In one embodiment, the device further includes:

[0093] A network status determination unit, configured to determine the network status according to the sending situation of the heartbeat packet;

[0094] A communication load determination unit, configured to determine the communication load status according to the content of the heartbeat packet;

[0095] A first heartbeat interval adjustment unit, configured to, when the network status is network fluctuation, shorten the corresponding heartbeat interval to a first preset value to obtain the adjusted heartbeat interval;

[0096] A second heartbeat interval adjustment unit, configured to, when the network status is network stability, extend the corresponding heartbeat interval in combination with the communication load status to obtain the adjusted heartbeat interval.

[0097] In one embodiment, the device further includes:

[0098] A first network status determination subunit, configured to, if the heartbeat packet is sent for a first preset number of times, and the network delay of each heartbeat packet is greater than a first preset delay threshold, or the jitter value of each heartbeat packet is greater than a first preset jitter threshold, determine that the network status is network fluctuation;

[0099] A second network status determination subunit, configured to, if the heartbeat packet is sent for a second preset number of times, and the network delay of each heartbeat packet is less than a second preset delay threshold and the jitter value of each heartbeat packet is lower than a second preset jitter threshold, determine that the network status is network stability.

[0100] In one embodiment, the device further includes:

[0101] A first communication load status determination subunit, configured to, if the control instruction frequency in the heartbeat packet is lower than a preset control instruction frequency and the data acquisition frequency is lower than a preset data acquisition frequency, determine that the communication load status is low load;

[0102] A second communication load status determination subunit, configured to, if the control instruction frequency in the heartbeat packet is higher than a preset control instruction frequency or the data acquisition frequency is higher than a preset data acquisition frequency, determine that the communication load status is high load.

[0103] In one embodiment, the device further includes:

[0104] The first heartbeat interval adjustment subunit is used to extend the corresponding heartbeat interval to a second preset value when the network state is stable and the communication load state is high load, and multiply the preset ratio by the second preset value to obtain the adjusted heartbeat interval.

[0105] The second heartbeat interval adjustment subunit is used to extend the corresponding heartbeat interval to a second preset value when the network state is stable and the communication load state is low load, to obtain the adjusted heartbeat interval.

[0106] In one embodiment, the device further includes:

[0107] The heartbeat packet suspension sending unit is used to suspend the sending of heartbeat packets if the data transmission state is that there is business data transmission.

[0108] In one embodiment, the device further includes:

[0109] The reconnection unit is used to determine that the TCP connection is interrupted if the edge gateway does not receive a heartbeat response after sending a heartbeat packet and exceeding the time threshold, and perform the TCP reconnection operation between the edge gateway and the cloud server.

[0110] Based on the above embodiments, the present invention also provides a terminal, and its structural schematic diagram can be as Figure 6 shown. The above terminal includes a processor, a memory, a network interface, and a display screen connected through a device bus. Among them, the processor of the terminal is used to provide computing and control capabilities. The memory of the terminal includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating device and an intelligent heartbeat keep-alive program. The internal memory provides an environment for the operation of the operating device and the intelligent heartbeat keep-alive program in the non-volatile storage medium. The network interface of the terminal is used to communicate with an external terminal through a network connection. When the intelligent heartbeat keep-alive program is executed by the processor, it realizes the steps of any one of the above intelligent heartbeat keep-alive methods. The display screen of the terminal can be a liquid crystal display screen or an electronic ink display screen.

[0111] Those skilled in the art can understand that Figure 6 the structural schematic diagram shown in

[0112] In one embodiment, a terminal is provided. The terminal includes a memory, a processor, and an intelligent heartbeat keep-alive program stored on the memory and executable on the processor. When the intelligent heartbeat keep-alive program is executed by the processor, the steps of any one of the intelligent heartbeat keep-alive methods provided by the embodiments of the present invention are implemented.

[0113] The embodiments of the present invention also provide a computer-readable storage medium. An intelligent heartbeat keep-alive program is stored on the computer-readable storage medium. When the intelligent heartbeat keep-alive program is executed by a processor, the steps of any one of the intelligent heartbeat keep-alive methods provided by the embodiments of the present invention are implemented.

[0114] It should be understood that the sequence numbers of the steps in the above embodiments do not mean the order of execution. The execution order of each process should be determined according to its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.

[0115] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the above division of each functional unit and module is used as an example. In actual applications, the above functions can be allocated to different functional units and modules according to needs, that is, the internal structure of the above device is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated into a processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit. In addition, the specific names of each functional unit and module are only for the convenience of mutual distinction and do not limit the protection scope of the present invention. The specific working process of the units and modules in the above device can refer to the corresponding process in the foregoing method embodiments and will not be described in detail here.

[0116] In the above embodiments, the descriptions of the various embodiments have their own emphases. For the parts not detailed or recorded in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0117] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed in this article can be implemented by electronic hardware, or by a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods for each specific application to implement the described functions, but such implementation should not be considered to exceed the scope of the present invention.

[0118] In the embodiments provided by the present invention, it should be understood that the disclosed device / terminal device and method can be implemented in other ways. For example, the device / terminal device embodiments described above are only illustrative. For example, the above-mentioned division of modules or units is only a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed.

[0119] The above-described 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 foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not deviate from the spirit and scope of the technical solutions of the present invention for the corresponding technical solutions, and should all be included in the protection scope of the present invention.

Claims

1. An intelligent heartbeat keep-alive method, characterized in that, The method includes: After the edge gateway and the cloud server establish a TCP connection, initialize the heartbeat interval and monitor the data transmission status between the edge gateway and the cloud server; If there is no business data transmission in the data transmission status, control the edge gateway to send a heartbeat packet to the cloud server at the heartbeat interval; Adjust the corresponding heartbeat interval based on the sending situation and content of the heartbeat packet; After each adjustment of the heartbeat interval, if there is no business data transmission in the data transmission status, control the edge gateway to send a heartbeat packet to the cloud server at the adjusted heartbeat interval.

2. The intelligent heartbeat keep-alive method according to claim 1, wherein Adjusting the corresponding heartbeat interval based on the sending situation and content of the heartbeat packet includes: Determine the network status according to the sending situation of the heartbeat packet; Determine the communication load status according to the content of the heartbeat packet; When the network status is network fluctuation, shorten the corresponding heartbeat interval to a first preset value to obtain the adjusted heartbeat interval; When the network status is network stable, extend the corresponding heartbeat interval in combination with the communication load status to obtain the adjusted heartbeat interval.

3. The intelligent heartbeat keep-alive method according to claim 2, wherein, Determining the network status according to the sending situation of the heartbeat packet includes: If the first preset number of heartbeat packets are sent, and the network delay of each heartbeat packet is greater than the first preset delay threshold, or the jitter value of each heartbeat packet is greater than the first preset jitter threshold, then determine that the network status is network fluctuation; If the second preset number of heartbeat packets are sent, and the network delay of each heartbeat packet is less than the second preset delay threshold and the jitter value of each heartbeat packet is lower than the second preset jitter threshold, then determine that the network status is network stable.

4. The intelligent heartbeat keep-alive method according to claim 2, wherein, Determining the communication load status according to the content of the heartbeat packet includes: If the control instruction frequency in the heartbeat packet is lower than the preset control instruction frequency and the data acquisition frequency is lower than the preset data acquisition frequency, then determine that the communication load status is low load; If the control instruction frequency in the heartbeat packet is higher than the preset control instruction frequency or the data acquisition frequency is higher than the preset data acquisition frequency, then determine that the communication load status is high load.

5. The intelligent heartbeat keep-alive method according to claim 2, wherein When the network status is network stable, extending the corresponding heartbeat interval in combination with the communication load status to obtain the adjusted heartbeat interval includes: When the network status is network stable and the communication load status is high load, extend the corresponding heartbeat interval to a second preset value and multiply the second preset value by a preset ratio to obtain the adjusted heartbeat interval; When the network status is network stable and the communication load status is low load, extend the corresponding heartbeat interval to a second preset value to obtain the adjusted heartbeat interval.

6. The intelligent heartbeat keep-alive method according to claim 1, wherein, The method further includes: if there is business data transmission in the data transmission status, suspend the sending of heartbeat packets.

7. The intelligent heartbeat keep-alive method according to claim 1, characterized in that, The method further includes: if the edge gateway does not receive a heartbeat response within a time threshold after sending a heartbeat packet, determine that the TCP connection is interrupted, and perform a TCP reconnection operation between the edge gateway and the cloud server.

8. An intelligent heartbeat keep-alive device, characterized in that, including: A monitoring module, used to initialize the heartbeat interval after the edge gateway and the cloud server establish a TCP connection, and monitor the data transmission status between the edge gateway and the cloud server; The first heartbeat sending module is configured to, if the data transmission status indicates no service data transmission, control the edge gateway to send heartbeat packets to the cloud server at a heartbeat interval; The interval adjustment module is configured to adjust the corresponding heartbeat interval based on the sending situation and content of the heartbeat packets; The second heartbeat sending module is configured to, after each adjustment of the heartbeat interval, if the data transmission status indicates no service data transmission, control the edge gateway to send heartbeat packets to the cloud server at the adjusted heartbeat interval.

9. A terminal, characterized in that, The terminal includes: a memory, a processor, and an intelligent heartbeat keep-alive program stored on the memory and executable on the processor. When the intelligent heartbeat keep-alive program is executed by the processor, the steps of the intelligent heartbeat keep-alive method according to any one of claims 1-7 are implemented.

10. A computer-readable storage medium, characterized in that, An intelligent heartbeat keep-alive program is stored on the computer-readable storage medium. When the intelligent heartbeat keep-alive program is executed by the processor, the steps of the intelligent heartbeat keep-alive method according to any one of claims 1-7 are implemented.