Automatic heartbeat monitoring method, system, equipment and medium
By dynamically adjusting the sending time interval of heartbeat packets and making real-time adjustments according to the server status, the waste of computing power and risk of disconnection caused by the fixed heartbeat interval in the existing technology is solved, and the stability and reliability of communication in the mobile Internet environment are improved.
Patent Information
- Application Number
- CN202410736450.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-07
- Publication Date
- 2024-09-13
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing heartbeat monitoring methods have problems with fixed heartbeat intervals on mobile devices, resulting in a waste of computing power or increased risk of disconnection, and fail to effectively respond to changes in the mobile Internet environment.
By dynamically adjusting the sending time interval of heartbeat packets and using different time steps according to the response status returned by the server, we ensure the real-time and accuracy of heartbeat monitoring.
It realizes the optimization of system resources in the mobile Internet environment, reduces computing power consumption and false alarm rate, and improves communication stability and reliability.
Smart Images

Figure CN118646685A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to an automatic heartbeat monitoring method, system, equipment and medium. Background Art
[0002] With the rapid development of mobile Internet, users have an increasing demand for real-time communication platforms, which, in addition to providing basic instant messaging functions, also support rich interaction methods such as voice calls and video conferencing. However, the complex network environment of mobile Internet poses challenges to the stability and reliability of communication links, which may lead to communication interruptions.
[0003] In order to ensure the connection between the client and the server, a heartbeat packet is needed to inform the other party of the status. However, the current heartbeat monitoring method has some defects on mobile devices, such as the problem of fixed heartbeat interval. Short intervals lead to waste of computing power, and long intervals increase the risk of disconnection; and the problem of multiple confirmations when the heartbeat times out. Even if a timeout or error occurs, a reconnection is initiated immediately, but due to the short time interval, the possibility of reconnection failure is relatively high, and changes in the mobile Internet environment are not taken into account. Summary of the invention
[0004] The object of the present invention is to provide an automatic heartbeat monitoring method, system, device and medium, so as to dynamically adjust the time interval for sending heartbeat packets and achieve the effect of optimizing system resources.
[0005] In order to achieve the above object, in a first aspect, the present invention provides an automatic heartbeat monitoring method, which is applied to a client and comprises: Initialize the time interval for sending heartbeat packets when there is no data interaction with the server; Send the heartbeat packet to the server according to the sending time interval, and monitor the status of the heartbeat response packet returned by the server within a timeout time interval; When the state is a normal heartbeat state, adjusting the sending time interval by using a first time step, and sending the heartbeat packet to the server according to the adjusted sending time interval; In the case where the state is an abnormal heartbeat state, a second time step is used to adjust the preset waiting time interval, and the heartbeat packet is sent to the server according to the adjusted waiting time interval.
[0006] In one embodiment, monitoring the status of the heartbeat response packet returned by the server includes: If the heartbeat response packet returned by the server has been received within the timeout period, the state is a normal heartbeat state; If the heartbeat response packet returned by the server is not received within the timeout period, the state is a heartbeat abnormal state.
[0007] In one embodiment, the adopting the first time step to adjust the sending time interval, and sending the heartbeat packet to the server according to the adjusted sending time interval, includes: Adjusting the sending time interval upward according to the first time step to obtain the adjusted sending time interval; The heartbeat packet is sent to the server according to the adjusted sending time interval.
[0008] In one embodiment, the method further comprises: Determining whether the adjusted sending time interval is greater than the timeout time interval; If so, stop increasing the sending time interval according to the first time step, and directly send the heartbeat packet to the server according to the timeout time interval.
[0009] In one embodiment, the step of adjusting the preset waiting time interval by using the second time step, and sending the heartbeat packet to the server according to the adjusted waiting time interval, includes: The preset waiting time interval is increased according to the second time step to obtain the adjusted waiting time interval; and the heartbeat packet is sent to the server according to the adjusted waiting time interval.
[0010] In one embodiment, when the state is an abnormal heartbeat state, before using the second time step to adjust the preset waiting time interval, the method further includes: Sending the heartbeat packet to the server according to the preset waiting time interval; In the case where the heartbeat response packet returned by the server has been received within the timeout period, the heartbeat normal state is returned.
[0011] In one embodiment, after sending the heartbeat packet to the server according to the adjusted waiting time interval, the method further includes: In the case where the heartbeat response packet returned by the server has been received within the timeout period, the heartbeat normal state is returned.
[0012] In a second aspect, an embodiment of the present invention provides an automatic heartbeat monitoring system, which is applied to a client and includes: An initialization module is used to initialize the sending time interval of the heartbeat packet when no data interaction occurs with the server; a monitoring status module is used to send the heartbeat packet to the server according to the sending time interval, and monitor the status of the heartbeat response packet returned by the server within a timeout time interval; A normal heartbeat module, used for, when the state is a normal heartbeat state, adjusting the sending time interval by a first time step, and sending the heartbeat packet to the server according to the adjusted sending time interval; The heartbeat abnormality module is used to adjust the preset waiting time interval by using a second time step when the state is a heartbeat abnormality state, and send the heartbeat packet to the server according to the adjusted waiting time interval.
[0013] In a third aspect, an embodiment of the present invention provides an electronic device, comprising Memory, processor, and A computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the automatic heartbeat monitoring method described in any one of the above is implemented.
[0014] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the program, when executed by a processor, implements any of the automatic heartbeat monitoring methods described above.
[0015] Compared with the prior art, the automatic heartbeat monitoring method, system, device and medium of the embodiment of the present invention have the following beneficial effects: The present invention is applied to a client, and by initializing the sending time interval of a heartbeat packet when no data interaction occurs with a server, the process of sending the heartbeat packet during the data interaction can be reduced, and computing power consumption and resource waste can be reduced. Then, the heartbeat packet is sent to the server according to the sending time interval, and the state of the heartbeat response packet returned by the server is monitored within the time interval of the timeout. By reasonably setting the sending time interval, the needs of timely monitoring the server state and reducing network traffic can be balanced. Reasonable setting of the timeout time interval can avoid judging the server state abnormality too early or too late, thereby ensuring the accuracy of monitoring. Then, when the state is a normal heartbeat state, the sending time interval is adjusted by a first time step, and the heartbeat packet is sent to the server according to the adjusted sending time interval; the dynamic adjustment of the sending time interval can respond to changes in the network and server states more timely, and ensure the real-time nature of heartbeat monitoring. Finally, when the state is an abnormal heartbeat state, the preset waiting time interval is adjusted by a second time step, and the heartbeat packet is sent to the server according to the adjusted waiting time interval. By adjusting the waiting time interval according to the second time step, the system can avoid false alarm abnormal states caused by temporary network fluctuations or server busyness, thereby reducing the false alarm rate. The present invention can dynamically adjust the time interval for sending heartbeat packets to optimize system resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings: Figure 1 A schematic diagram of a flow chart of an automatic heartbeat monitoring method provided by an embodiment of the present invention; Figure 2 A schematic diagram of a process of monitoring a status of a heartbeat response packet returned by a server according to an embodiment of the present invention; Figure 3 A schematic diagram of the process of step S103 provided in an embodiment of the present invention; Figure 4 A schematic diagram of the process after step 302 provided in an embodiment of the present invention; Figure 5 A schematic diagram of the process of step S104 provided in an embodiment of the present invention; Figure 6 A schematic diagram of a process flow before the second time step is used to adjust the preset waiting time interval provided by an embodiment of the present invention; Figure 7 A flow chart of the process after sending a heartbeat packet to a server according to the adjusted waiting time interval provided by an embodiment of the present invention; Figure 8A schematic diagram of a process for establishing a connection with a server provided in an embodiment of the present invention; Fig. 9 A block diagram of an automatic heartbeat monitoring system provided by an embodiment of the present invention; Fig.10 A schematic diagram of the internal structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0017] The specific implementation of the present invention is further described in detail below in conjunction with the accompanying drawings and examples. The following examples are used to illustrate the present invention, but are not intended to limit the scope of the present invention.
[0018] Obviously, the drawings described below are only some examples or embodiments of the present invention. For ordinary technicians in this field, the present invention can also be applied to other similar scenarios based on these drawings without creative work. In addition, it can also be understood that although the efforts made in this development process may be complicated and lengthy, for ordinary technicians in this field related to the content disclosed by the present invention, some changes in design, manufacturing or production based on the technical content disclosed by the present invention are just conventional technical means, and should not be understood as insufficient content disclosed by the present invention.
[0019] Reference to "embodiments" in the present invention means that the specific features, structures, or characteristics described in conjunction with the embodiments may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those of ordinary skill in the art that the embodiments described in the present invention may be combined with other embodiments without conflict.
[0020] Unless otherwise defined, the technical terms or scientific terms involved in the present invention shall be the ordinary meanings understood by people with ordinary skills in the technical field to which the present invention belongs. The words "one", "a", "a", "the" and the like involved in the present invention do not indicate a quantity limitation and may indicate the singular or plural. The terms "include", "comprise", "have" and any of their variations involved in the present invention are intended to cover non-exclusive inclusions; for example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units that are not listed, or may also include other steps or units inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in the present invention are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in the present invention refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" may indicate: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects in the front and back relation are in an "or" relationship. The terms "first", "second", "third" and the like involved in the present invention are only used to distinguish similar objects and do not represent a specific ordering of the objects.
[0021] At present, the heartbeat monitoring method usually adopts a fixed heartbeat interval. This interval can be short or long. Short intervals will frequently send heartbeat requests, increasing computing power consumption; long intervals may make it impossible to detect communication failures in time, increasing the possibility of disconnection. Regardless of the length of the interval, when a heartbeat request times out or an error occurs, an attempt to reconnect too quickly may increase system resource consumption. In a mobile Internet environment, fluctuations in network status may also cause reconnection failures. Therefore, how to dynamically adjust the time interval for sending heartbeat packets to minimize computing power consumption while ensuring communication stability has become a problem that needs to be solved at present.
[0022] Based on the above situation, the embodiments of the present invention provide an automatic heartbeat monitoring method, system, device and medium.
[0023] In a first aspect, an embodiment of the present invention provides an automatic heartbeat monitoring method. Figure 1 A flow chart of an automatic heartbeat monitoring method provided by an embodiment of the present invention is shown as follows: Figure 1 As shown, the method is applied to the client and includes the following steps: Step S101, initializing the time interval for sending heartbeat packets when no data interaction occurs with the server.
[0024] Step S102: Send a heartbeat packet to the server according to the sending time interval, and monitor the status of the heartbeat response packet returned by the server within the timeout time interval.
[0025] Step S103: When the state is a normal heartbeat state, the sending time interval is adjusted using the first time step, and a heartbeat packet is sent to the server according to the adjusted sending time interval.
[0026] Step S104: When the state is an abnormal heartbeat state, the preset waiting time interval is adjusted using the second time step, and a heartbeat packet is sent to the server according to the adjusted waiting time interval.
[0027] The client includes but is not limited to user devices such as mobile phones, mobile computers, tablet computers, smart TVs, smart watches, and smart glasses. Specifically, when the client does not interact with the server for data, it will initialize the sending time interval of the heartbeat packet to ensure that there is a suitable sending frequency in the initial stage, avoid sending the heartbeat packet too frequently, and thus save computing power and network bandwidth. Then, the client will send a heartbeat packet to the server according to the sending time interval, and monitor the state of the heartbeat response packet returned by the server within the timeout period to ensure smooth communication. If the heartbeat state is normal, the client will adjust the sending time interval according to the first time step, and dynamically send a heartbeat packet to the server to adapt to changes in the network state and improve the stability and efficiency of communication. When the heartbeat state is abnormal, the client will adjust the waiting time interval according to the second time step, and send a heartbeat packet to the server according to the adjusted waiting time interval to maintain the stability of communication. Therefore, by dynamically adjusting the time interval for sending heartbeat packets, system resources are optimized.
[0028] In one embodiment, Figure 2 A flow chart of the state of the monitoring server returning the heartbeat response packet provided by the embodiment of the present invention is as follows: Figure 2 As shown, in Figure 1 Based on the process shown, monitoring the status of the heartbeat response packet returned by the server includes the following steps: Step S201: If the heartbeat response packet returned by the server has been received within the timeout period, the state is a normal heartbeat state.
[0029] Step S202: If the heartbeat response packet returned by the server is not received within the timeout period, the state is a heartbeat abnormal state.
[0030] Specifically, if the heartbeat response packet returned by the server has been received within the timeout interval, the client's status will be considered to be in a normal heartbeat state. This indicates that the communication between the client and the server is smooth, and the sending and receiving of the heartbeat packet are completed within the expected time range. If the heartbeat response packet returned by the server is not received within the timeout interval, the client's status will be considered to be in an abnormal heartbeat state. This indicates that there is a communication problem between the client and the server, which may be caused by network delays, connection interruptions, or other reasons. This enables real-time monitoring and management of the communication status between the client and the server, thereby improving the stability and reliability of communication.
[0031] In one embodiment, Figure 3 A flow chart of step S103 provided in an embodiment of the present invention is shown in FIG. Figure 3 As shown, in Figure 1 Based on the process shown, the sending time interval is adjusted by using the first time step, and a heartbeat packet is sent to the server according to the adjusted sending time interval, including the following steps: Step S301: Increase the sending time interval according to the first time step to obtain an adjusted sending time interval.
[0032] Specifically, when the communication state between the client and the server is judged to be a normal heartbeat state, the client will increase the sending time interval according to the first time step. Therefore, when the communication is normal, the client will gradually extend the sending time interval of the heartbeat packet to reduce the sending frequency of the heartbeat packet, thereby reducing the load and network bandwidth occupation.
[0033] For example, set the timeout to T MAX , the initialization heartbeat packet sending time interval is T1, the first time step is T a After the client increases the sending time interval according to the first time step, the adjusted sending time interval T2 = T1 + T a , preferably, T a = 5 seconds. This time step can provide more precise adjustment, allowing the client to more accurately and dynamically adjust the heartbeat packet sending interval according to actual conditions.
[0034] It should also be noted that the time interval for sending the initialization heartbeat packet is half of the timeout period, that is, T1 = 1 / 2T MAX .
[0035] Step S302: Send a heartbeat packet to the server according to the adjusted sending time interval.
[0036] Specifically, after the adjusted sending time interval is determined, the client will send heartbeat packets to the server according to this interval. This ensures that when communication is normal, the client will still send heartbeat packets regularly to maintain the connection with the server, but the sending frequency will be adjusted according to the communication status and time step. In the subsequent stages, the sending frequency will be gradually reduced, thereby saving network resource consumption.
[0037] In one embodiment, Figure 4 The flowchart after step 302 provided in the embodiment of the present invention is as follows: Figure 4 As shown, in Figure 3 Based on the process shown, the method further includes the following steps: Step S401: Determine whether the adjusted sending time interval is greater than the timeout time interval.
[0038] Step S402: If yes, stop increasing the sending time interval according to the first time step, and directly send the heartbeat packet to the server according to the timeout time interval.
[0039] Specifically, in order to ensure that the sending time interval does not cause the heartbeat packet to be sent too low, thereby causing the connection stability to decrease, it is necessary to judge whether the adjusted sending time interval is greater than the timeout time interval, if the adjusted sending time interval is greater than the timeout time interval, stop increasing according to the first time step, and directly send the heartbeat packet to the server according to the timeout time interval. It can be achieved that a reasonable frequency is maintained when sending the heartbeat packet, the sending delay of the heartbeat packet is reduced as much as possible, and the real-time performance of the communication is improved.
[0040] In one embodiment, Figure 5 A flow chart of step S104 provided in an embodiment of the present invention is shown in FIG. Figure 5 As shown, in Figure 1 Based on the process shown, the preset waiting time interval is adjusted by using the second time step, and a heartbeat packet is sent to the server according to the adjusted waiting time interval, including the following steps: Step S501: Increase the preset waiting time interval according to the second time step to obtain an adjusted waiting time interval.
[0041] Step S502: Send a heartbeat packet to the server according to the adjusted waiting time interval.
[0042] Particularly, because accidental network fluctuations may cause heartbeat request failure, the client does not receive the heartbeat response packet returned by the server, and if a new heartbeat packet is initiated immediately to the server, the probability of failure may be very large, therefore, it is necessary to pre-set the waiting time interval to send the heartbeat packet to the server, if the heartbeat response packet returned by the server is not received in the timeout interval, the waiting time interval is raised according to the second time step, and the waiting time interval after adjustment is obtained. That is, the waiting time interval is dynamically adjusted according to actual conditions, to adapt to the different situations of the change of the network environment. By dynamically adjusting the waiting time interval, the adaptability of the system to network abnormalities can be improved.
[0043] In one embodiment, Figure 6 A flow chart of a process before the second time step is used to adjust the preset waiting time interval is provided in an embodiment of the present invention, such as Figure 6 As shown, in Figure 1 Based on the process shown, when the state is an abnormal heartbeat state, before using the second time step to adjust the preset waiting time interval, the method further includes the following steps: Step S601: Send a heartbeat packet to a server according to a preset waiting time interval.
[0044] Step S602: When a heartbeat response packet returned by the server has been received within the timeout period, the heartbeat returns to a normal state.
[0045] Specifically, it is necessary to pre-set a waiting time interval to send a heartbeat packet to the server. If a heartbeat response packet returned by the server has been received within the preset timeout time interval, the heartbeat normal state is returned, indicating that the server has successfully received and responded to the heartbeat packet sent by the client, and the connection status is normal.
[0046] In one embodiment, Figure 7 A flow chart of the process after sending a heartbeat packet to a server according to the adjusted waiting time interval provided by an embodiment of the present invention is as follows: Figure 7 As shown, in Figure 1 Based on the process shown, after sending the heartbeat packet to the server according to the adjusted waiting time interval, the method further includes the following steps: Step S701: When a heartbeat response packet returned by the server has been received within a timeout period, the heartbeat returns to a normal state.
[0047] Specifically, if the heartbeat response packet returned by the server has been received within the preset timeout time interval, the heartbeat normal state is returned. This indicates that the server has successfully received and responded to the heartbeat packet sent by the client, and the connection state is normal. That is, the waiting time interval is dynamically adjusted according to the actual situation to adapt to the different situations of changes in the network environment. By dynamically adjusting the waiting time interval, the system's ability to adapt to network abnormalities can be improved.
[0048] For example, the preset waiting time interval is T3, and the second time step is T b After the client increases the waiting time interval according to the second time step, the adjusted waiting time interval T4 = T3 + T b , preferably, T3 = 5 seconds, T b = 5 seconds. Therefore, the frequency of sending heartbeat packets can be reduced by increasing the waiting time interval, thereby reducing the probability of failure. By increasing the waiting time interval, the client can give the server more response time to restore the connection. At the same time, setting a reasonable waiting time interval can also save network resources.
[0049] In one embodiment, the adjusted waiting time interval is greater than or equal to the timeout time interval, confirming that the heartbeat has failed.
[0050] Specifically, when the accumulated waiting time interval after increment is greater than or equal to the timeout time interval, it can be confirmed that the heartbeat has failed, and the client can display a reminder of disconnection from the server on its own display interface to inform the user that the network environment needs to be checked. There may be network disconnection, power outage, abnormal program termination, etc. At the same time, the client can try to reconnect by itself. Timely discovery and handling of communication failures improves the stability and reliability of communication between the client and the server.
[0051] In one embodiment, Figure 8 A schematic diagram of a process for establishing a connection with a server provided in an embodiment of the present invention, such as Figure 8 As shown, in Figure 1 Based on the process shown, the method further includes the following steps: Step S801: Establish a connection with a server.
[0052] Step S802: When data interaction occurs with the server, stop sending heartbeat packets to the server.
[0053] Specifically, in order to improve the stability of the communication connection between the client and the server and reduce the occupation of network resources and computing power consumption to a certain extent, when data interaction occurs with the server, it means that the client and the server have normal data interaction and there is no need to send heartbeat packets to the server to maintain the connection.
[0054] The specific implementation of the present invention is described below in conjunction with a specific application scenario. This embodiment is implemented by the following steps: Step 1001: Establish a communication connection between the client and the server. After the client and the server are successfully connected and there is no data interaction between the client and the server, initialize the heartbeat packet sending time interval T1.
[0055] Step 1002: according to the sending time interval T1=1 / 2T MAX Send a heartbeat packet to the server and MAX The monitoring server returns the status of the heartbeat response packet.
[0056] Step 1003: If the time interval T exceeds MAX If the heartbeat response packet returned by the server has been received within 1 second, the status is normal; When the heartbeat is in a normal state, the sending time interval T1 is set to the first time step T a Adjust upward to get the adjusted sending time interval T2 = T1 + T a ; The heartbeat packet is sent to the server according to the adjusted sending time interval T2.
[0057] Determine whether the adjusted sending time interval T2 is greater than the timeout time interval T MAX ; If so, stop increasing the sending time interval according to the first time step, and directly send the heartbeat packet to the server according to the timeout time interval.
[0058] Step 1004: If the time interval T exceeds MAX If the heartbeat response packet returned by the server is not received within 10 seconds, the status is abnormal.
[0059] Send a heartbeat packet to the server according to the preset waiting time interval T3; At the timeout interval T MAX If the heartbeat response packet returned by the server has been received, execute step 1003; At the timeout interval T MAX If the heartbeat response packet returned by the server is not received within 10 seconds, the waiting time interval T3 is adjusted according to the second time step T b Adjust upward to obtain the adjusted waiting time interval T4 = T3 + T b ; A heartbeat packet is sent to the server according to the adjusted waiting time interval T4.
[0060] The adjusted waiting time interval T4 is greater than or equal to the timeout time interval T MAX, confirming that the heartbeat failed. The client can display a reminder of disconnection from the server on its own display interface to inform the user that the network environment needs to be checked. There may be network disconnection, power outage, abnormal program termination, etc. At the same time, the client can try to reconnect by itself. Timely discover and handle communication failures to improve the stability and reliability of communication between the client and the server.
[0061] Step 1005: When data is being exchanged between the client and the server, stop sending heartbeat packets to the server; after the client completes receiving the service data, reinitialize the time interval for sending the heartbeat packets and execute step 1003.
[0062] It should be noted that the steps shown in the above process or the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0063] In a second aspect, an embodiment of the present invention provides an automatic heartbeat monitoring system, which is used to implement the above-mentioned embodiments and preferred implementation modes, and will not be repeated hereafter. As used below, the terms "module", "unit", "subunit", etc. may be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0064] Fig. 9 A block diagram of an automatic heartbeat monitoring system provided by an embodiment of the present invention, such as Fig. 9 As shown, applied to a client, the system includes: The initialization module 901 is used to initialize the time interval for sending heartbeat packets when no data interaction occurs with the server.
[0065] The monitoring status module 902 is used to send the heartbeat packet to the server according to the sending time interval, and monitor the status of the heartbeat response packet returned by the server within a timeout time interval.
[0066] The heartbeat normal module 903 is used to adjust the sending time interval by using the first time step when the state is the heartbeat normal state, and send the heartbeat packet to the server according to the adjusted sending time interval.
[0067] The heartbeat abnormality module 904 is used to adjust the preset waiting time interval by using the second time step when the state is the heartbeat abnormality state, and send the heartbeat packet to the server according to the adjusted waiting time interval.
[0068] It should be noted that the above modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.
[0069] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the automatic heartbeat monitoring method described above when executing the computer program.
[0070] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0071] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation modes, and this embodiment will not be described in detail here.
[0072] In a fourth aspect, in combination with the automatic heartbeat monitoring method in the above embodiment, the embodiment of the present invention can provide a storage medium for implementation. The storage medium stores a computer program; when the computer program is executed by a processor, any automatic heartbeat monitoring method in the above embodiment is implemented.
[0073] In one embodiment, a computer device is provided, which may be a terminal. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, an automatic heartbeat monitoring method is implemented. The display screen of the computer device may be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device may be a touch layer covered on the display screen, or a key, trackball, or touchpad provided on the housing of the computer device, or an external keyboard, touchpad, or mouse, etc.
[0074] In one embodiment, Fig.10 A schematic diagram of the internal structure of an electronic device provided by an embodiment of the present invention, such as Fig.10 As shown, an electronic device is provided, which may be a server, and its internal structure diagram may be as shown in Fig.10As shown. The electronic device includes a processor, a network interface, an internal memory and a non-volatile memory connected through an internal bus, wherein the non-volatile memory stores an operating system, a computer program and a database. The processor is used to provide computing and control capabilities, the network interface is used to communicate with an external terminal through a network connection, the internal memory is used to provide an environment for the operation of the operating system and the computer program, the computer program is executed by the processor to implement the automatic heartbeat monitoring method, and the database is used to store data.
[0075] Those skilled in the art will understand that Fig.10 The structure shown in the figure is only a block diagram of a part of the structure related to the scheme of the present invention, and does not constitute a limitation on the electronic device to which the scheme of the present invention is applied. The specific electronic device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0076] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0077] Those skilled in the art should understand that the technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0078] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and substitutions can be made without departing from the technical principles of the present invention. These improvements and substitutions should also be regarded as the scope of protection of the present invention.
Claims
1. An automatic heartbeat monitoring method, It is characterized in that The method is applied to a client, and the method comprises: Initialize the time interval for sending heartbeat packets when there is no data interaction with the server; Send the heartbeat packet to the server according to the sending time interval, and monitor the status of the heartbeat response packet returned by the server within a timeout time interval; When the state is a normal heartbeat state, adjusting the sending time interval by using a first time step, and sending the heartbeat packet to the server according to the adjusted sending time interval; In the case where the state is an abnormal heartbeat state, a second time step is used to adjust the preset waiting time interval, and the heartbeat packet is sent to the server according to the adjusted waiting time interval.
2. The method according to claim 1, It is characterized in that The monitoring of the status of the heartbeat response packet returned by the server includes: If the heartbeat response packet returned by the server has been received within the timeout interval, the state is a normal heartbeat state; If the heartbeat response packet returned by the server is not received within the timeout period, the state is a heartbeat abnormal state.
3. The method according to claim 1, It is characterized in that The step of adjusting the sending time interval by using the first time step, and sending the heartbeat packet to the server according to the adjusted sending time interval, comprises: Adjusting the sending time interval upward according to the first time step to obtain the adjusted sending time interval; The heartbeat packet is sent to the server according to the adjusted sending time interval.
4. The method according to claim 3, It is characterized in that The method further comprises: Determining whether the adjusted sending time interval is greater than the timeout time interval; If so, stop increasing the sending time interval according to the first time step, and directly send the heartbeat packet to the server according to the timeout time interval.
5. The method according to claim 1, It is characterized in that The step of adjusting the preset waiting time interval by using the second time step, and sending the heartbeat packet to the server according to the adjusted waiting time interval, comprises: The preset waiting time interval is increased according to the second time step to obtain the adjusted waiting time interval; and the heartbeat packet is sent to the server according to the adjusted waiting time interval.
6. The method according to claim 1, It is characterized in that When the state is an abnormal heartbeat state, before the second time step is used to adjust the preset waiting time interval, the method further includes: Sending the heartbeat packet to the server according to the preset waiting time interval; In the case where the heartbeat response packet returned by the server has been received within the timeout period, the heartbeat normal state is returned.
7. The method according to claim 1, It is characterized in that After sending the heartbeat packet to the server according to the adjusted waiting time interval, the method further includes: In the case where the heartbeat response packet returned by the server has been received within the timeout period, the heartbeat normal state is returned.
8. An automatic heart rate monitoring system, It is characterized in that The system is applied to a client, and the system includes: An initialization module is used to initialize the time interval for sending heartbeat packets when no data interaction occurs with the server; A monitoring status module, used for sending the heartbeat packet to the server according to the sending time interval, and monitoring the status of the heartbeat response packet returned by the server within a timeout time interval; A normal heartbeat module, used for, when the state is a normal heartbeat state, adjusting the sending time interval by a first time step, and sending the heartbeat packet to the server according to the adjusted sending time interval; The heartbeat abnormality module is used to adjust the preset waiting time interval by using a second time step when the state is a heartbeat abnormality state, and send the heartbeat packet to the server according to the adjusted waiting time interval.
9. An electronic device, It is characterized in that include Memory, processor, and A computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the automatic heartbeat monitoring method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the automatic heartbeat monitoring method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
WIFI anomaly automatic reconnection device, system and method
CN106332159A
Terminal equipment, heartbeat packet sending interval detection method thereof and storage medium
CN114268565A
Lease-based heartbeat protocol method and apparatus
US20170251063A1
Configuration management in a communication network
WO2017157459A1
Cited By
Communication terminal and low-power-consumption control method and system thereof
CN120583496A
