A communication method, system and related devices
By sending different types of heartbeat messages on business connections and probe connections respectively, and by using a server set to provide business and probe services, the problem of reduced battery life caused by frequent heartbeat message sending is solved, and power consumption is reduced and the stability of business data transmission is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUAWEI TECH CO LTD
- Filing Date
- 2024-01-10
- Publication Date
- 2026-04-24
AI Technical Summary
Frequent heartbeat messages reduce the battery life of electronic devices, and current technology cannot effectively solve this problem.
By sending different types of heartbeat messages on the service connection and the probe connection respectively, a new heartbeat cycle is determined based on the probe connection, reducing the sending frequency of heartbeat messages on the service connection, and using a set of servers to provide service and probe services respectively.
It reduces the power consumption of electronic devices, improves battery life, and avoids interruptions in business data transmission.
Smart Images

Figure CN119996479B_ABST
Abstract
Description
[0001] This application is a divisional application. The original application has the application number 202410045849.4 and the original application date is January 10, 2024. The entire contents of the original application are incorporated herein by reference. Technical Field
[0002] This application relates to the field of communications, and more particularly to a communication method, system and related apparatus. Background Technology
[0003] With the continuous development of communication technology, more and more electronic devices can connect to the Internet through gateways and communicate with other electronic devices on the Internet.
[0004] The gateway has a timeout period. If the communication interval between the electronic device and the gateway exceeds this timeout period, the communication connection between the electronic device and the gateway will be disconnected. Therefore, after establishing a communication connection with the gateway, the electronic device needs to frequently send heartbeat messages to the gateway to avoid the communication connection being disconnected due to timeout.
[0005] However, frequent heartbeat messages can consume power and affect the battery life of electronic devices. Summary of the Invention
[0006] This application provides a communication method, system, and related apparatus that determines a new heartbeat cycle based on a detected connection, thereby reducing the frequency of heartbeat message transmission on the service connection, reducing power consumption, and improving the battery life of electronic devices.
[0007] In a first aspect, this application provides a communication method applied to a first electronic device, the method comprising: establishing a first connection between the first electronic device and a server; sending a first type of heartbeat message to the server through the first connection based on a first period; establishing a second connection between the first electronic device and the server, the second connection being used to transmit a second type of heartbeat message; determining a second period based on the second connection; sending a first type of heartbeat message to the server through the first connection based on the second period; and disconnecting the second connection.
[0008] In this way, service data can be transmitted on the first connection (i.e., the service connection), and the heartbeat cycle can be detected on the second connection (i.e., the probe connection), thus avoiding interruption of service data transmission during the probe process.
[0009] In one possible implementation, the server is a set of servers, including a first server and a second server; the first server is used to establish a first connection with a first electronic device, and the second server is used to establish a second connection with the first electronic device.
[0010] In this way, business services and probing services can be provided by different servers in the server set, which allows for better control over data transmission on different connections.
[0011] In one possible implementation, the second cycle is longer than the first cycle.
[0012] This reduces the frequency of heartbeat messages sent on the service connection, lowers power consumption, and improves battery life.
[0013] In one possible implementation, the first electronic device establishes a second connection with the server, specifically including: when a detection condition is detected, the first electronic device establishes a second connection with the server; wherein the detection condition includes any one or more of the following: the first electronic device establishes a communication connection with the server for the first time, the time since the last detection reaches a first duration, the first operation is received from the user, the first operation is used to instruct the first electronic device to determine a second period, and a detection instruction is received, the detection instruction is used to instruct the first electronic device to determine a second period.
[0014] In this way, a detection connection (i.e., a second connection) can be established when the detection conditions are met, and a second cycle can be determined based on the detection connection.
[0015] In one possible implementation, the format of the first type of heartbeat message is the same as that of the second type of heartbeat message; or, the format of the first type of heartbeat message is different from that of the second type of heartbeat message.
[0016] In one possible implementation, the first type of heartbeat message contains more content than the second type of heartbeat message. This saves power consumption when sending the second type of heartbeat message.
[0017] In one possible implementation, the moment when the first electronic device establishes a second connection with the server is the first moment; determining a second period based on the second connection specifically includes: at the second moment, sending a first message to the server through the second connection, the first message being a second type of heartbeat message, the second moment being later than the first moment; receiving a first response, the first response being the server's response to the first message sent through the second connection; when a stopping condition is detected, determining the second period based on the time interval between the first moment and the second moment.
[0018] In one possible implementation, the second period is the time interval between the first and second moments, or the second period is the difference between the time interval between the first and second moments and the fourth constant.
[0019] In this way, when the stopping condition is detected, the second period can be determined based on the heartbeat period corresponding to the most recent successfully sent heartbeat message on the second connection.
[0020] In one possible implementation, the time interval between the first and second moments is: the product of the first period and the first constant, where the first constant is a positive number greater than 1; or, the sum of the first period and the second constant, where the second constant is a positive number; or, the average of the first period and the third constant, where the third constant is greater than the first period.
[0021] In this way, the next heartbeat cycle on the second connection can be determined based on the first cycle.
[0022] In one possible implementation, the method further includes: before the first moment, sending a second message to the server via the second connection, the second message being a second type of heartbeat message; detecting that the second connection is broken; and at the first moment, the first electronic device re-establishing the second connection with the server.
[0023] In this way, after the second connection is broken, the second connection can be re-established, and the second cycle can be determined based on the re-established second connection.
[0024] In one possible implementation, determining the second period based on the second connection specifically includes: at a third time, sending a third message to the server through the second connection, the third message being a second type of heartbeat message; receiving a third response, the third response being the server's response to the third message sent through the second connection; at a fourth time, sending a fourth message to the server through the second connection, the fourth message being a second type of heartbeat message, the fourth time being later than the third time; receiving a fourth response, the fourth response being the server's response to the fourth message sent through the second connection; and when a stopping condition is detected, determining the second period based on the time interval between the third time and the fourth time.
[0025] In one possible implementation, the second period is the time interval between the third and fourth time points, or the second period is the difference between the time interval between the third and fourth time points and the fourth constant.
[0026] In this way, when the stopping condition is detected, the second period can be determined based on the heartbeat period corresponding to the most recent successfully sent heartbeat message on the second connection.
[0027] In one possible implementation, the moment when the first electronic device establishes a second connection with the server is a first moment, the time interval between the first moment and the third moment is a first time interval, and the time interval between the third moment and the fourth moment is a second time interval; the first time interval is less than the second time interval; the method further includes: before the first moment, sending a second message to the server through the second connection, the first message being a second type of heartbeat message; detecting that the second connection is broken; and at the first moment, the first electronic device re-establishes a second connection with the server.
[0028] In this way, after the second connection is broken, the second connection can be re-established, and the second cycle can be determined based on the re-established second connection.
[0029] In one possible implementation, the second time interval is: the product of the first time interval and a first constant, where the first constant is a positive number greater than 1; or, the sum of the first time interval and a second constant, where the second constant is a positive number; or, the average of the first time interval and a third constant, where the third constant is greater than the first time interval.
[0030] In this way, the next heartbeat cycle of the second connection can be determined based on the current heartbeat cycle of the second connection.
[0031] In one possible implementation, before determining the second period based on the second connection, the method further includes: after receiving the third response, sending a first type of heartbeat message to the server based on the third period through the first connection, wherein the third period is the time interval between the first moment and the third moment.
[0032] In this way, during the determination of the second cycle, the heartbeat cycle of the first connection can be updated in real time based on the detection results on the second connection.
[0033] In one possible implementation, before determining the second period based on the second connection, the method further includes: after receiving the third response, sending a first type of heartbeat message to the server via the first connection based on the third period, wherein the third period is the difference between the time interval between the first moment and the third moment and a fourth constant.
[0034] In this way, during the determination of the second cycle, the heartbeat cycle of the first connection can be updated in real time based on the detection results on the second connection. Moreover, the heartbeat cycle of the first connection can be prevented from being equal to the timeout period by introducing a fixed error (i.e., a fourth constant).
[0035] In one possible implementation, before the third time point, the method further includes: at the fifth time point, sending a fifth message to the server via the second connection, the fifth message being a second type of heartbeat message; receiving a fifth response, the fifth response being the server's response to the fifth message sent via the second connection; wherein the time interval between the fifth time point and the third time point is the third time interval, the time interval between the third time point and the fourth time point is the second time interval, and the third time interval is less than the second time interval.
[0036] In this way, when the stopping condition is detected, the second period can be determined based on the heartbeat period corresponding to the most recent successfully sent heartbeat message on the second connection.
[0037] In one possible implementation, the second time interval is: the product of the third time interval and the first constant, where the first constant is a positive number greater than 1; or, the sum of the third time interval and the second constant, where the second constant is a positive number; or, the average of the third time interval and the third constant, where the third constant is greater than the third time interval.
[0038] In this way, the next heartbeat cycle of the second connection can be determined based on the current heartbeat cycle of the second connection.
[0039] In one possible implementation, before determining the second period based on the second connection, the method further includes: after receiving the third response, sending a first type of heartbeat message to the server based on the fourth period through the first connection; the fourth period is the time interval between the fifth time and the third time, or the fourth period is the difference between the time interval between the fifth time and the third time and a fourth constant.
[0040] In this way, during the determination of the second cycle, the heartbeat cycle of the first connection can be updated in real time based on the detection results on the second connection. Furthermore, a fixed error (i.e., a fourth constant) can be introduced to prevent the heartbeat cycle of the first connection from coinciding with the timeout period.
[0041] In one possible implementation, the moment when the first electronic device establishes a second connection with the server is designated as the first moment; determining the second period based on the second connection specifically includes: at a sixth moment, sending a sixth message to the server through the second connection, the sixth message being a type 2 heartbeat message, the sixth moment being later than the first moment; receiving a sixth response, the sixth response being the server's response to the sixth message sent through the second connection; at a seventh moment, sending a seventh message to the server through the second connection, the seventh message being a type 2 heartbeat message, the seventh moment being later than the sixth moment; detecting that the second connection is broken; and when a stopping condition is detected, determining the second period based on the time interval between the first moment and the sixth moment.
[0042] In one possible implementation, the second period is the time interval between the first time point and the sixth time point, or the second period is the difference between the time interval between the first time point and the sixth time point and the fourth constant.
[0043] In this way, when the stopping condition is detected, the second period can be determined based on the heartbeat period corresponding to the most recent successfully sent heartbeat message on the second connection.
[0044] In one possible implementation, determining the second period based on the second connection specifically includes: at time eight, sending an eighth message to the server via the second connection, the eighth message being a type two heartbeat message; receiving an eighth response, the eighth response being the server's response to the eighth message sent via the second connection; at time nine, sending a ninth message to the server via the second connection, the ninth message being a type two heartbeat message, time nine being later than time eight; receiving a ninth response, the ninth response being the server's response to the ninth message sent via the second connection; at time ten, sending a tenth message to the server via the second connection, the tenth message being a type two heartbeat message, time ten being later than time nine; detecting that the second connection is broken; and when a stopping condition is detected, determining the second period based on the time interval between time eight and time nine.
[0045] In one possible implementation, the second period is the time interval between the eighth and ninth times, or the second period is the difference between the time interval between the eighth and ninth times and the fourth constant.
[0046] In this way, when the stopping condition is detected, the second period can be determined based on the heartbeat period corresponding to the most recent successfully sent heartbeat message on the second connection.
[0047] In one possible implementation, the stopping conditions include any one or more of the following: the probe duration reaches a second duration, the number of times a second type of heartbeat message is sent through the second connection reaches a first count, and the number of times the second connection is established reaches a second count.
[0048] In one possible implementation, after the first electronic device establishes a second connection with the server, the method further includes: at an eleventh moment, sending a first type of heartbeat message to the server through the first connection; at a twelfth moment, sending an eleventh message to the server through the second connection, the eleventh message being a second type of heartbeat message, the twelfth moment being later than the eleventh moment, and the time interval between the eleventh moment and the twelfth moment being a fourth time interval; at the twelfth moment, sending a first type of heartbeat message to the server through the first connection, the absolute value of the difference between the fourth time interval and the first period being less than a first threshold.
[0049] In this way, by aligning the sending times of heartbeat messages on the first and second connections, the number of times the first electronic device needs to be woken up can be reduced, thereby lowering the power consumption of the first electronic device.
[0050] In one possible implementation, the first electronic device establishes a first connection with the server, specifically including: the first electronic device establishes a first connection with the server through a second electronic device; the first electronic device establishes a second connection with the server, specifically including: the first electronic device establishes a second connection with the server through a second electronic device.
[0051] In this way, the first electronic device can establish a communication connection with the server through the second electronic device.
[0052] In one possible implementation, the method further includes: establishing a third connection between the first electronic device and the server; determining a second period based on the second connection, specifically including: determining the second period based on the second connection and the third connection.
[0053] The third connection is used to transmit the second type of heartbeat message.
[0054] In this way, the second cycle can be determined based on multiple probe connections.
[0055] Secondly, this application provides an electronic device, namely a first electronic device, which includes one or more processors and one or more memories. The one or more memories are coupled to the one or more processors, and the one or more memories are used to store computer program code, which includes computer instructions. When the one or more processors execute the computer instructions, the first electronic device performs the communication method in any possible implementation of any of the above aspects.
[0056] Thirdly, embodiments of this application provide a readable storage medium including instructions that, when executed on a first electronic device, cause the first electronic device to perform the communication method in any of the possible implementations of any of the above aspects.
[0057] Fourthly, embodiments of this application provide a computer program product that, when run on a first electronic device, causes the first electronic device to execute the communication method in any of the possible implementations of any of the above aspects.
[0058] The beneficial effects of the second to fourth aspects can be referenced from the beneficial effects of the first aspect mentioned above.
[0059] Fifthly, embodiments of this application provide a server, which is a set of servers, including a first server and a second server. The first server is used to establish a first connection with a first electronic device, and the second server is used to establish a second connection with the first electronic device. The first connection is used to transmit business data and a first type of heartbeat message, and the second connection is used to transmit a second type of heartbeat message.
[0060] In this way, business services and probing services can be provided by different servers in the server set, which allows for better control over data transmission on different connections. Attached Figure Description
[0061] Figure 1A A schematic diagram illustrating the relationship between an intranet, an extranet, and a public network is provided for embodiments of this application.
[0062] Figure 1B A schematic diagram illustrating the communication connection between an electronic device A1 and a communication network C, provided as an embodiment of this application;
[0063] Figure 2A A schematic diagram of the system architecture of a communication system 10 provided in an embodiment of this application;
[0064] Figure 2B A schematic diagram illustrating the communication connection between an electronic device 100 and a server 300, provided as an embodiment of this application;
[0065] Figure 3A A schematic diagram of the hardware structure of an electronic device 100 provided in an embodiment of this application;
[0066] Figure 3B A schematic diagram of the hardware structure of a server 300 provided in an embodiment of this application;
[0067] Figure 4 A flowchart illustrating a communication method provided in an embodiment of this application;
[0068] Figure 5 A schematic diagram illustrating the process of determining a heartbeat cycle 2 based on a communication connection 2 in an electronic device 100 according to an embodiment of this application;
[0069] Figure 6 This application provides a schematic diagram of the process of sending service heartbeat messages by electronic device 100 on communication connection 1 during the detection heartbeat cycle 2.
[0070] Figure 7 A schematic diagram illustrating the timing of an electronic device 100 sending heartbeat messages on communication connection 1 and communication connection 2, provided as an embodiment of this application;
[0071] Figure 8 This application provides a schematic diagram illustrating the execution of the business server 310 and the detection server 320 in server 300 during the detection heartbeat cycle 2.
[0072] Figure 9 A functional module diagram of a communication system 10 provided in an embodiment of this application;
[0073] Figure 10 This is a flowchart illustrating a communication method provided in an embodiment of this application. Detailed Implementation
[0074] The technical solutions in the embodiments of this application will be clearly and thoroughly described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B; the word "and / or" in the text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more than two.
[0075] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature, and in the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.
[0076] The term "user interface (UI)" used in the following embodiments of this application refers to the medium interface through which an application or operating system interacts and exchanges information with the user. It realizes the conversion between the internal form of information and the form that the user can accept. The user interface is source code written in a specific computer language such as Java or Extensible Markup Language (XML). The interface source code is parsed and rendered on the electronic device, ultimately presenting content that the user can recognize. A common form of user interface is the graphical user interface (GUI), which refers to a user interface related to computer operation displayed graphically. It can be visible interface elements such as text, icons, buttons, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, and widgets displayed on the screen of an electronic device.
[0077] The following is an introduction to some terms used in this application.
[0078] Local Area Network (LAN): A LAN is a communication network that connects multiple electronic devices within a specific area. A LAN is a closed network and can consist of two or more electronic devices. Through dedicated data lines, a LAN can connect to other LANs or databases in other locations to form a larger-scale information processing system.
[0079] Intranet: If an electronic device is currently in a communication network, then that communication network can be considered the intranet of the electronic device. An intranet is a type of local area network (LAN).
[0080] External network: If an electronic device is currently in a communication network, then any other communication network outside of that network can be considered the external network of that electronic device. Generally speaking, a firewall is erected between the internal network and the external network. The area inside the firewall can be called the internal network, and the area outside the firewall can be called the external network.
[0081] Public network: The communication network that electronic devices on a local area network (LAN) can access through a gateway is called the public network. A public network can be a local area network (LAN) or a wide area network (WAN). In some application scenarios, the public network can refer to the Internet. For more detailed information on LANs, WANs, and public networks, please refer to the following... Figure 1A The relevant descriptions in the illustrated embodiments.
[0082] Internet Protocol (IP) address: An Internet Protocol (IP) address is a standardized address format provided by the IP protocol. It assigns a logical address to every network and every host on the Internet, thereby masking the differences in physical addresses. The IP protocol is designed for communication between interconnected computer networks.
[0083] Internal network IP address: An internal network IP address, also known as a local area network (LAN) address, is used by electronic devices to communicate with other electronic devices within the same LAN. An internal network IP address is unique within that LAN.
[0084] Public IP address: A public IP address can be used for communication on the public network. A public IP address is unique within the public network. Since there are a large number of electronic devices on the public network, assigning a public IP address to each one is impractical. Therefore, when electronic devices on a private network access the public network through a gateway, the gateway can translate the private network IP address into a valid public IP address, and then use that public IP address to access the public network.
[0085] Network Address Translation (NAT): NAT is a technology that translates internal network IP addresses into legitimate public network IP addresses. NAT allows electronic devices on an internal network to access the public network and communicate with other electronic devices on the public network. NAT not only solves the problem of insufficient public IP addresses but also effectively prevents attacks from the external network, hiding and protecting electronic devices on the internal network.
[0086] Gateway: A gateway is a point of entry connecting one communication network to another. Electronic devices on a local network can access the public network through a gateway, which may have NAT (Network Address Translation) functionality. In some applications, a gateway can also refer to a device with NAT capabilities. It's important to note that routers, computers, and other electronic devices with NAT functionality can all be considered gateways.
[0087] Timeout Period: The timeout period (aging time) is also known as the aging period. When an electronic device on an internal network accesses the public network through a gateway, the gateway configures a valid public IP address for the device using NAT technology. However, this public IP address has a timeout period. When the public IP address has not been used for longer than the timeout period, the gateway will age the public IP address, at which point the electronic device can no longer use this public IP address to access the public network.
[0088] Heartbeat messages: Heartbeat messages are data transmitted multiple times over a communication connection to maintain that connection. When internal network electronic devices access the public network through a gateway, the internal network electronic devices can establish a communication connection with devices on the public network through the gateway. As mentioned above regarding timeout periods, if the public network IP address ages, the communication connection between the electronic device and the public network will be lost. Therefore, to maintain this communication connection, the electronic device needs to send heartbeat messages multiple times over the communication connection to prevent the public network IP address from aging and thus avoid the connection from being lost. In some application scenarios, heartbeat messages are also called heartbeat packets.
[0089] Heartbeat cycle: On a communication connection, electronic devices can send heartbeat messages at fixed time intervals. This fixed time interval can be called the heartbeat cycle of the communication connection. It should be noted that the heartbeat cycle on a communication connection can be changed; that is, the heartbeat cycle on a communication connection can be different in different time periods.
[0090] Low-power state: A low-power state refers to a state in which the power consumption of an electronic device is lower than its normal power consumption. In a low-power state, the power consumption of the central processing unit (CPU) or microcontroller unit (MCU) is low, and the CPU (or MCU) needs to be woken up to work normally. When the electronic device sends or receives a heartbeat message, it can wake up the CPU (or MCU) and switch the electronic device from a low-power state to an operating state. In the embodiments of this application, waking up the electronic device refers to switching the electronic device from a low-power state to an operating state.
[0091] Operating status: Operating status refers to the state in which the power consumption of an electronic device remains at normal power consumption. In operating status, the CPU (or MCU) can work normally.
[0092] The following examples illustrate the relationship between intranet, extranet, and public network.
[0093] Figure 1A This diagram illustrates the relationship between an intranet, an extranet, and a public network.
[0094] like Figure 1A As shown, communication network A may include electronic devices A1 and A2, communication network B may include electronic devices B1 and B2, and communication network C may include electronic devices C1 and C2. Communication network C may also include communication network A and communication network B. Wherein:
[0095] Communication network A can be viewed as the intranet of electronic devices A1 and A2, communication network B can be viewed as the extranet of electronic devices A1 and A2, and communication network C can be viewed as the public network of communication network A. Electronic device A2 can act as a gateway to establish a communication connection with communication network C, enabling electronic device A1 to communicate with electronic devices in communication network C (such as electronic devices C1, C2, and electronic devices in communication network B) through electronic device A2.
[0096] Communication network B can be viewed as the intranet of electronic devices B1 and B2, communication network A can be viewed as the extranet of electronic devices B1 and B2, and communication network C can be viewed as the public network of communication network B. Electronic device B1 can act as a gateway to establish a communication connection with communication network C, enabling electronic device B2 to communicate with electronic devices in communication network C (such as electronic devices C1, C2, and electronic devices in communication network A) through electronic device B1.
[0097] Understandable, Figure 1A The embodiments shown are merely illustrative of the relationship between intranet, extranet and public network. In the embodiments of this application, each communication network may also include more or fewer electronic devices than the above embodiments, or may include more or fewer communication networks than the above embodiments or different from the above embodiments. This application does not limit this.
[0098] The following describes how electronic devices on an intranet can communicate with electronic devices on the public network through a gateway.
[0099] Figure 1B A schematic diagram of the communication connection between electronic device A1 and communication network C is shown.
[0100] like Figure 1BAs shown, electronic devices A1 and A2 belong to communication network A. Communication network A and communication network C can be referred to the above. Figure 1A The relevant description in the illustrated embodiment. Electronic device A2 can act as a gateway, enabling electronic device A1 to connect to the communication network C via electronic device A2.
[0101] Electronic device A1 can have an internal network IP address, and it can establish a communication connection with electronic device A2 based on this internal network IP address. Electronic device A2 has NAT functionality and can configure a public network IP address for electronic device A1. Based on this public network IP address, electronic device A1 can establish a communication connection with any device in the communication network C through electronic device A2.
[0102] Based on the aforementioned timeout period, it can be seen that the public IP address configured by electronic device A2 for electronic device A1 has a timeout period. Before the timeout, electronic device A2 can maintain the communication connection between electronic device A1 and communication network C. In this case, electronic device A1 can communicate with communication network C through electronic device A2 using the public IP address. If the timeout occurs, electronic device A2 can age the public IP address originally configured for electronic device A1. In this case, electronic device A1 can no longer communicate with communication network C through electronic device A2 using the original public IP address. After the timeout, if electronic device A1 still needs to communicate with devices in communication network C, electronic device A2 can assign a new public IP address to electronic device A1 and establish a communication connection with devices in communication network C based on the newly assigned public IP address.
[0103] It is understandable that if electronic device A1 and devices in communication network C exchange service data, a break in the communication connection between electronic device A1 and communication network C would affect the transmission of service data between them. Electronic device A1 can maintain the communication connection by sending multiple heartbeat messages through this connection. Breaking the communication connection can be avoided if the transmission interval between any two adjacent data transmissions (e.g., service data, heartbeat messages, etc.) on this connection is less than the timeout period.
[0104] In some embodiments, electronic device A1 can set a heartbeat period for the communication connection, which can be shorter than the timeout period. Electronic device A1 can send heartbeat messages to the communication network C through the communication connection at fixed time intervals based on the heartbeat period. Thus, even if the communication connection does not transmit service data for a period of time, electronic device A2 can maintain the communication connection between electronic device A1 and the communication network C based on the heartbeat messages.
[0105] It should be noted that if electronic device A1 is in a low-power state, each time it sends or receives a heartbeat message, it will switch from the low-power state to the working state. The power consumption required for electronic device A1 to switch from the low-power state to the working state is relatively large. Understandably, the shorter the heartbeat cycle, the more times electronic device A1 sends heartbeat messages within the same time period, resulting in higher power consumption and poorer battery life.
[0106] Therefore, electronic device A1 needs to determine a heartbeat cycle that is less than the timeout period and has the smallest difference from the timeout period in order to reduce the power consumption of electronic device A1 while maintaining the communication connection.
[0107] In some embodiments, electronic device A1 may be configured with a detection step size (e.g., 30 seconds, 1 minute, etc.). When electronic device A1 has established a communication connection with communication network C, electronic device A1 can determine a new heartbeat cycle based on the sum of the current heartbeat cycle and the detection step size. It then determines whether the updated heartbeat cycle can maintain the communication connection based on whether each heartbeat message is successfully sent, until the largest possible heartbeat cycle that can maintain the communication connection is detected. Based on the detected heartbeat cycle, a heartbeat message is sent to maintain the communication connection. This increases the heartbeat cycle on the communication connection and reduces the heartbeat message sending frequency, which can reduce the power consumption of electronic device A1 and prevent the communication connection from being disconnected. However, during the process of detecting the largest possible heartbeat cycle that can maintain the communication connection, the communication connection may be disconnected, which will affect the transmission of service data.
[0108] The following describes the system architecture of a communication system 10 provided in an embodiment of this application.
[0109] Figure 2A A schematic diagram of the system architecture of a communication system 10 provided in an embodiment of this application is shown.
[0110] like Figure 2A As shown, the communication system 10 may include electronic device 100, electronic device 200, and server 300. Wherein:
[0111] One or more communication connections can be established between electronic device 100 and electronic device 200, such as communication connection A1 and communication connection A2. One or more communication connections can be established between electronic device 200 and server 300, such as communication connection B1 and communication connection B2.
[0112] Electronic device 100 can establish one or more communication connections with server 300, such as communication connection 1 and communication connection 2. Communication connection 1 and communication connection 2 are the communication connections between electronic device 100 and server 300. Among them, communication connection 1 may include the aforementioned communication connection A1 and communication connection B1, and communication connection 2 may include the aforementioned communication connection A2 and communication connection B2.
[0113] Communication connection 1 can be used to transmit service data between electronic device 100 and server 300. Electronic device 100 can perform corresponding services based on the transmitted service data, such as video playback, audio playback, web browsing, call services, and game services. Therefore, in this embodiment, the communication connection used to transmit service data can also be called a service connection, and communication connection 1 is a service connection. Communication connection 1 can also be used to transmit service heartbeat messages. The service heartbeat messages are used to maintain communication connection 1 and prevent communication connection 1 from being disconnected due to exceeding the timeout period of electronic device 200. Electronic device 100 can send service heartbeat messages to server 300 on communication connection 1 based on heartbeat period 1.
[0114] Communication connection 2 can be used to detect heartbeat cycle 2. In this embodiment, the communication connection used to detect heartbeat cycle 2 can also be called a detection connection, and communication connection 2 is a detection connection. Communication connection 2 can be used to transmit detection heartbeat messages. The detection heartbeat messages are used to detect heartbeat cycle 2. Electronic device 100 can determine heartbeat cycle 2 by changing the sending time interval of the detection heartbeat messages and whether each detection heartbeat message is successfully sent. It is understood that during the detection of heartbeat cycle 2, communication connection 2 may be disconnected and re-established once or multiple times. In some other embodiments, the detection connection between electronic device 100 and server 300 may also include multiple communication connections. In this case, electronic device 100 can detect heartbeat cycle 2 through these multiple communication connections, which is not limited in this application.
[0115] After determining heartbeat cycle 2, electronic device 100 can change the period for sending heartbeat messages on the service connection (e.g., communication connection 1) to heartbeat cycle 2, and can also disconnect the probe connection (e.g., communication connection 2).
[0116] Electronic device 200 can act as a gateway, converting the internal network IP address of electronic device 100 into a public network IP address and connecting electronic device 100 with server 300. In other embodiments, electronic device 200 can also connect electronic device 100 to other electronic devices. In some embodiments, electronic device 200 can be a router or other types of electronic devices; this application does not limit the device type of electronic device 200.
[0117] In some embodiments, server 300 may include one or more server modules, and each server module may have different functions. In other embodiments, server 300 may also be regarded as a server cluster including multiple servers, and in this server cluster, each server may have different functions; this application does not limit this. Further details about server 300 can be found below. Figure 2B The relevant descriptions in the illustrated embodiments will not be detailed here.
[0118] It is understandable that the above Figure 2A The illustrated embodiment is merely an example. In some embodiments, the electronic device 100 and the server 300 may include more devices (such as routers), which is not limited herein. Furthermore, the communication system 10 may include more electronic devices, or electronic devices of different types than those in the above embodiments, which is not limited herein.
[0119] Figure 2B This illustration shows a communication connection diagram between an electronic device 100 and a server 300 according to an embodiment of this application.
[0120] like Figure 2B As shown, server 300 may include business server 310 and probe server 320.
[0121] In some embodiments, server 300 may include multiple server modules. In this case, business server 310 may be one or more server modules in server 300, and probe server 320 may also be one or more server modules in server 300.
[0122] In other embodiments, server 300 may be a server cluster including multiple servers. In this case, business server 310 may be one or more servers in the server cluster, and probe server 320 may also be one or more servers in the server cluster.
[0123] In server 300, service server 310 can provide service to electronic device 100, and service server 300 can establish a service connection with electronic device 100 through electronic device 200 (e.g., as described above). Figure 2A The embodiment shown illustrates communication connection 1), through which service data is sent and received, enabling electronic device 100 to perform corresponding services, such as video playback, audio playback, call services, game services, and web browsing services. The detection server 320 can establish one or more detection connections with electronic device 100 via electronic device 200, as described above. Figure 2A Communication connection 2 in the illustrated embodiment. Electronic device 100 can determine heartbeat cycle 2 based on one or more detection connections.
[0124] In this way, different server modules in server 300 can provide business services and probe services to electronic device 100 respectively, and isolate the probe service from the business service, so that server 300 can better control the data transmission on the business connection and the probe connection.
[0125] It is understandable that the above Figure 2B The illustrated embodiment is merely an example; in this application embodiment, server 300 may also include components other than those described above. Figure 2B The embodiments shown may contain more or fewer server modules (or servers) or may differ from the embodiments described above; this application does not limit the scope of the invention.
[0126] It should be noted that in some other embodiments, server 300 may not include probe server 320. In this case, service server 310 can establish service connection and probe connection with electronic device 100 through electronic device 200. Service server 310 can control the service connection to send and receive service data and control the probe connection to receive probe heartbeat messages sent by electronic device 100.
[0127] The hardware structure of an electronic device 100 provided in the embodiments of this application is described below.
[0128] Figure 3A This illustration shows a schematic diagram of the hardware structure of an electronic device 100 provided in an embodiment of this application.
[0129] Electronic device 100 may be a mobile phone, tablet computer, desktop computer, laptop computer, handheld computer, notebook computer, ultra-mobile personal computer (UMPC), netbook, as well as cellular phone, personal digital assistant (PDA), augmented reality (AR) device, virtual reality (VR) device, artificial intelligence (AI) device, wearable device, in-vehicle device, smart home device and / or smart city device. The embodiments of this application do not impose any special restrictions on the specific type of electronic device.
[0130] Electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, antenna 1, antenna 2, a mobile communication module 150, a wireless communication module 160, etc. Optionally, electronic device 100 may also include one or more of the following: an audio module 170, a sensor module 180, buttons 190, a motor 191, an indicator 192, a display screen 194, etc. The sensor module 180 may include a touch sensor 180K. Optionally, the sensor module 180 may also include one or more of the following: a pressure sensor, a gyroscope sensor, a barometric pressure sensor, a magnetic sensor, an accelerometer, a distance sensor, a proximity sensor, a fingerprint sensor, a temperature sensor, an ambient light sensor, a bone conduction sensor, etc.
[0131] It is understood that the structures illustrated in the embodiments of the present invention do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0132] Processor 110 may include one or more processing units, such as application processors (APs), modem processors, graphics processing units (GPUs), image signal processors (ISPs), controllers, video codecs, digital signal processors (DSPs), baseband processors, and / or neural network processing units (NPUs). These different processing units may be independent devices or integrated into one or more processors.
[0133] The controller can generate operation control signals based on the instruction opcode and timing signals to complete the control of instruction fetching and execution.
[0134] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0135] In some embodiments, the processor 110 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0136] The charging management module 140 receives charging input from a charger. The charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 receives charging input from the wired charger via the USB interface 130. In some wireless charging embodiments, the charging management module 140 receives wireless charging input via the wireless charging coil of the electronic device 100. While charging the battery 142, the charging management module 140 can also supply power to the electronic device via the power management module 141.
[0137] The power management module 141 connects the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, providing power to the processor 110, internal memory 121, display screen 194, and wireless communication module 160, etc. The power management module 141 can also monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage current, impedance). In some other embodiments, the power management module 141 may also be located within the processor 110. In other embodiments, the power management module 141 and the charging management module 140 may be located in the same device.
[0138] The wireless communication function of electronic device 100 can be realized through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor and baseband processor, etc.
[0139] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover one or more communication frequency bands. Different antennas can also be multiplexed to improve antenna utilization. For example, antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with tuning switches.
[0140] The mobile communication module 150 can provide solutions for wireless communication, including 2G / 3G / 4G / 5G, applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves via antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to a modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via antenna 1. In some embodiments, at least some functional modules of the mobile communication module 150 may be housed in the processor 110. In some embodiments, at least some functional modules of the mobile communication module 150 and at least some modules of the processor 110 may be housed in the same device.
[0141] The modem processor may include a modulator and a demodulator. The modulator modulates the low-frequency baseband signal to be transmitted into a mid-to-high frequency signal. The demodulator demodulates the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After processing by the baseband processor, the low-frequency baseband signal is transmitted to the application processor. The application processor outputs sound signals through an audio device (not limited to speaker 170A, receiver 170B, etc.) or displays images or videos through the display screen 194. In some embodiments, the modem processor may be a separate device. In other embodiments, the modem processor may be independent of the processor 110 and may be housed in the same device as the mobile communication module 150 or other functional modules.
[0142] The wireless communication module 160 can provide solutions for wireless communication applications on the electronic device 100, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via antenna 2, demodulates and filters the electromagnetic wave signals, and sends the processed signal to processor 110. The wireless communication module 160 can also receive signals to be transmitted from processor 110, frequency modulate and amplify them, and then convert them into electromagnetic waves for radiation via antenna 2.
[0143] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, enabling electronic device 100 to communicate with networks and other devices via wireless communication technology. The wireless communication technology may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technologies, etc. The GNSS may include the Global Positioning System (GPS), the Global Navigation Satellite System (GLONASS), the BeiDou Navigation Satellite System (BDS), the Quasi-Zenith Satellite System (QZSS), and / or satellite-based augmentation systems (SBAS).
[0144] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0145] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), or it can be manufactured using organic light-emitting diodes (OLEDs), active-matrix organic light-emitting diodes (AMOLEDs), flexible light-emitting diodes (FLEDs), minimized LEDs, microLEDs, micro-OLEDs, quantum dot light-emitting diodes (QLEDs), etc. In some embodiments, electronic device 100 may include one or N displays 194, where N is a positive integer greater than 1.
[0146] Internal memory 121 may include one or more random access memory (RAM) and one or more non-volatile memory (NVM).
[0147] The random access memory can be directly read and written by the processor 110. It can be used to store executable programs (such as machine instructions) of the operating system or other running programs, as well as user and application data.
[0148] Non-volatile memory can also store executable programs and user and application data, and can be pre-loaded into random access memory for direct reading and writing by the processor 110.
[0149] The external memory interface 120 can be used to connect to external non-volatile memory, thereby expanding the storage capacity of the electronic device 100. The external non-volatile memory communicates with the processor 110 through the external memory interface 120 to perform data storage functions. For example, music, video, and other files can be stored in the external non-volatile memory.
[0150] The audio module 170 may include one or more of the following: a speaker 170A, a receiver 170B, a microphone 170C, etc. In some embodiments, the electronic device 100 may implement audio functions through the audio module 170 and an application processor, such as music playback and recording.
[0151] The audio module 170 is used to convert digital audio information into analog audio signals for output, and also to convert analog audio input into digital audio signals. The audio module 170 can also be used for encoding and decoding audio signals. In some embodiments, the audio module 170 may be located in the processor 110, or some functional modules of the audio module 170 may be located in the processor 110.
[0152] The speaker 170A, also known as a "loudspeaker," is used to convert audio electrical signals into sound signals. The electronic device 100 can listen to music or make hands-free calls through the speaker 170A.
[0153] The receiver 170B, also known as the "earpiece," is used to convert audio electrical signals into sound signals. When the electronic device 100 answers a telephone call or voice message, the receiver 170B can be brought close to the ear to listen to the voice.
[0154] Microphone 170C, also known as a "microphone" or "voice transducer," is used to convert sound signals into electrical signals. When making a phone call or sending a voice message, the user can speak by bringing their mouth close to microphone 170C, inputting the sound signal into microphone 170C. Electronic device 100 may have at least one microphone 170C. In some embodiments, electronic device 100 may have two microphones 170C, which, in addition to collecting sound signals, can also perform noise reduction. In other embodiments, electronic device 100 may also have three, four, or more microphones 170C, which can collect sound signals, reduce noise, identify the sound source, and perform directional recording, etc.
[0155] Touch sensor 180K, also known as a "touch device," can be located on display screen 194. The touch sensor 180K and display screen 194 together form a touchscreen, also known as a "touchscreen." Touch sensor 180K detects touch operations applied to or near it. The touch sensor can transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through display screen 194. In other embodiments, touch sensor 180K may also be located on the surface of electronic device 100, in a different position than display screen 194.
[0156] Buttons 190 include a power button, volume buttons, etc. Buttons 190 can be mechanical buttons or touch-sensitive buttons. Electronic device 100 can receive button input and generate key signal inputs related to user settings and function control of electronic device 100.
[0157] Motor 191 can generate vibration alerts. Motor 191 can be used for incoming call vibration alerts or for touch vibration feedback. For example, different vibration feedback effects can correspond to touch operations performed on different applications (such as taking photos, playing audio, etc.). Motor 191 can also correspond to different vibration feedback effects for touch operations performed on different areas of the display screen 194. Different application scenarios (such as time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also be customized.
[0158] Indicator 192 can be an indicator light, used to indicate charging status, power changes, or to indicate messages, missed calls, notifications, etc.
[0159] It is understood that, in some embodiments, the hardware structure of the electronic device 200 may also refer to [the relevant source]. Figure 3A The hardware structure of the electronic device 100 shown may vary in some embodiments, with the electronic device 200 potentially including components different from those described above. Figure 3A The present application does not limit the number of devices shown in the embodiments, the number of devices shown, or the devices that are different from those in the above embodiments.
[0160] Figure 3B This is a schematic diagram of the hardware structure of a server 300 provided in an embodiment of this application.
[0161] like Figure 3B As shown, server 300 may include one or more network device processors 301, memory 302, communication interface 303, transmitter 305, receiver 306, coupler 307, and antenna 308. These components can be connected via bus 304 or other means. Figure 3B Taking a bus connection as an example:
[0162] The communication interface 303 can be used by the server 300 to communicate with other communication devices, such as electronic devices used by consumers of the project. Specifically, the communication interface 303 can be a 3G communication interface, a Long Term Evolution (LTE) (4G) communication interface, a 5G communication interface, a WLAN communication interface, a WAN communication interface, etc. Not limited to wireless communication interfaces, the server 300 can also be configured with a wired communication interface 303 to support wired communication.
[0163] In some embodiments of this application, transmitter 305 and receiver 306 can be considered as a wireless modem. Transmitter 305 can be used to transmit signals output by network device processor 301. Receiver 306 can be used to receive signals. In server 300, the number of transmitters 305 and receivers 306 can be one or more. Antenna 308 can be used to convert electromagnetic energy in a transmission line into electromagnetic waves in free space, or to convert electromagnetic waves in free space into electromagnetic energy in a transmission line. Coupler 307 can be used to split mobile communication signals into multiple paths and distribute them to multiple receivers 306. Understandably, the antenna 308 of the network device can be implemented as a massive MIMO (Massively Multi-Size Antenna Array).
[0164] The memory 302 is coupled to the network device processor 301 and is used to store various software programs and / or multiple sets of instructions. Specifically, the memory 302 may include high-speed random access memory and may also include non-volatile memory, such as one or more disk storage devices, flash memory devices, or other non-volatile solid-state storage devices.
[0165] The memory 302 can store an operating system (hereinafter referred to as the system), such as uCOS, VxWorks, RTLinux and other embedded operating systems. The memory 302 can also store a network communication program, which can be used to communicate with other communication devices.
[0166] In this embodiment, the network device processor 301 can be used to read and execute computer-readable instructions. Specifically, the network device processor 301 can be used to call a program stored in the memory 302, such as an implementation program of the communication method provided in one or more embodiments of this application, and execute the instructions contained in the program.
[0167] Understandable Figure 3B The illustrated embodiment is merely an example. In the embodiments of this application, server 300 may also include more, fewer, or different devices than those in the above embodiments, and this application does not impose limitations here. It should be noted that in some other embodiments, the hardware structure of a server module in server 300 (or a server in the server cluster corresponding to server 300) may also refer to the above. Figure 3B The relevant descriptions in the illustrated embodiments will not be repeated here.
[0168] This application provides a communication method in which an electronic device 100 can establish a communication connection 1 with a server 300, and the electronic device 100 can interact with the server 300 for business data based on communication connection 1. The electronic device 100 sends a business heartbeat message to the server 300 based on a heartbeat cycle 1 on communication connection 1. The electronic device 100 can also establish a communication connection 2 with the server 300 and send a probe heartbeat message to the server 300 through communication connection 2. The electronic device 100 can determine the heartbeat cycle 2 based on communication connection 2. After determining the heartbeat cycle 2, the electronic device 100 can send a business heartbeat message to the server 300 on communication connection 1 based on the heartbeat cycle 2, and then disconnect communication connection 2.
[0169] In this way, electronic device 100 can maintain communication connection 1 based on the heartbeat cycle 2 determined on communication connection 2, reducing power consumption caused by the transmission of heartbeat messages. Moreover, during the determination of heartbeat cycle 2, communication connection 1 is always maintained, and service data is transmitted on communication connection 1, which can avoid interruption of service data during the detection process.
[0170] Figure 4 A flowchart illustrating a communication method provided in an embodiment of this application is shown.
[0171] like Figure 4 As shown, the specific process of the communication method may include the following steps:
[0172] S401. Electronic device 100 establishes communication connection 1 with server 300, and electronic device 100 sends business heartbeat message to server 300 based on heartbeat cycle 1 through communication connection 1.
[0173] In some embodiments, the specific method by which the electronic device 100 establishes a communication connection (e.g., communication connection 1, communication connection 2, etc.) with the server 300 can refer to the method of establishing a TCP long connection, which will not be described in detail here.
[0174] Electronic device 100 can establish a communication connection 1 with server 300 through electronic device 200. Communication connection 1 can be used to send and receive business data so that electronic device 100 can perform corresponding business (such as video playback business, audio playback business, web browsing business, chat business, game business, etc.).
[0175] In this embodiment of the application, the heartbeat message sent on communication connection 1 can be called a service heartbeat message, and the heartbeat message sent on communication connection 2 (or other probe connection) can be called a probe heartbeat message.
[0176] The following describes the composition of the business heartbeat message and the probe heartbeat message.
[0177] For example, Table 1 shows the content composition of service heartbeat messages sent on service connections and probe heartbeat messages sent on probe connections.
[0178] Table 1
[0179]
[0180] As shown in Table 1, the service heartbeat message sent on the service connection may include the following: encryption protocol, device registration information, authentication information, key information, and heartbeat message identifier count. The probe heartbeat message sent on the probe connection may include the heartbeat message identifier count, and optionally, may also include an encryption protocol. The encryption protocol indicates the encryption protocol used for the data in the heartbeat message. The device registration information indicates that the sending device of the heartbeat message is electronic device 100. The authentication information can be used to indicate the permissions of electronic device 100, for example, to indicate whether electronic device 100 has permission to obtain service data from server 300. The key information may include the key for the heartbeat message. For example, in the service heartbeat message, the key information and encryption protocol can be used to decrypt the service heartbeat message. The heartbeat message identifier count can indicate the number of fields in the heartbeat message. As shown in Table 1, the number of fields in the service heartbeat message can be M1, and the number of fields in the probe heartbeat message can be M2. M1 can be greater than or equal to M2. For example, M1 can be 3, and M2 can be 1.
[0181] It is understood that the embodiments shown in Table 1 are only examples. In other embodiments, the service heartbeat message and the probe heartbeat message may include more, less or different content than the above embodiments. This application does not limit this.
[0182] In other embodiments, the content composition of the probe heartbeat message may be the same as that of the service heartbeat message, and this application does not limit it here.
[0183] It should be noted that after the electronic device 100 establishes communication connection 1 with the server 300, in order to maintain the communication connection 1, the electronic device 100 can send multiple service heartbeat messages to the server 300 through the communication connection.
[0184] Heart rate cycle 1 can be a preset time length, such as 5 seconds, 30 seconds, 3 minutes, 5 minutes, etc.
[0185] In some embodiments, after establishing communication connection 1, electronic device 100 can send service heartbeat messages to server 300 at fixed time intervals through communication connection 1, thereby preventing communication connection 1 from being disconnected. This fixed time interval is the duration corresponding to heartbeat cycle 1.
[0186] In other embodiments, after establishing communication connection 1, electronic device 100 can first send a service heartbeat message based on heartbeat cycle 1, then update the heartbeat cycle of communication connection 1 based on subsequent detection results on communication connection 2, and send a service heartbeat message based on the updated heartbeat cycle. The method for updating the heartbeat cycle of communication connection 1 can be referred to below. Figure 6 The relevant descriptions in the illustrated embodiments will not be detailed here.
[0187] S402. When the detection conditions are met, the electronic device 100 establishes a communication connection with the server 300.
[0188] The detection conditions may include, but are not limited to, any one or more of the following: the electronic device 100 is initially connected to a communication network; the time elapsed since the last heartbeat detection cycle of the electronic device 100 reaches a preset time (e.g., 5 days, 10 days, or 14 days); the electronic device 100 receives a user's operation to detect the heartbeat cycle; the electronic device 100 receives a detection command sent by another electronic device; the detection command is used to instruct the electronic device 100 to detect the heartbeat cycle, etc.
[0189] When the detection conditions are met, the electronic device 100 can establish one or more detection connections with the server 300 through the electronic device 200. These one or more detection connections can be used to detect the heartbeat cycle 2.
[0190] In some embodiments, the one or more probe connections may include communication connection 2.
[0191] In other embodiments, the one or more probe connections may also include communication connection 2 and other communication connections, which are not limited herein.
[0192] S403. Electronic device 100 determines heartbeat cycle 2 based on communication connection 2.
[0193] Electronic device 100 can determine the heartbeat cycle 2 on communication connection 2 using any of the following methods: binary search, stepwise probing, exponential probing.
[0194] For example, Figure 5 This paper illustrates a flowchart of how an electronic device 100 determines a heartbeat cycle 2 based on a communication connection 2, according to an embodiment of this application.
[0195] S501. Electronic device 100 determines a detection range, which includes an upper detection limit and / or a lower detection limit.
[0196] Electronic device 100 may first determine a detection range. The detection range may include an upper detection limit and / or a lower detection limit.
[0197] In some embodiments, the electronic device 100 may determine the lower limit of the detection range based on the heartbeat cycle 1 in step S401. For example, if the heartbeat cycle 1 is T0, then the lower limit of the detection range is determined to be T0. After determining the lower limit of the detection range, the electronic device 100 may determine the detection range as [T0, +∞] or determine the detection range as [T0, K*T0], where K is a preset positive number.
[0198] It is understood that this is just an example. In the embodiments of this application, the electronic device 100 may also determine the detection interval based on other preset time thresholds, or determine the detection interval in a way different from the above embodiments. This application does not limit this.
[0199] S502. Electronic device 100 updates the heartbeat cycle of communication connection 2 based on the detection interval, and the value of the heartbeat cycle belongs to the detection interval.
[0200] The detection range includes an upper detection limit and / or a lower detection limit. Electronic device 100 can determine the heartbeat cycle of communication connection 2 based on the upper detection limit and / or the lower detection limit. For example, electronic device 100 can calculate the heartbeat cycle of communication connection 2 using any one of the following formulas (1) to (3).
[0201] Heartbeat cycle = (upper detection limit + lower detection limit) / 2 Formula (1)
[0202] In the above formula (1), the heart rate cycle can be the average of the upper and lower detection limits.
[0203] Heartbeat cycle = detection lower limit + step size formula (2)
[0204] In the above formula (2), the heart rate cycle can be the sum of the detection limit and the step size. The step size can be a preset duration (e.g., 30 seconds, 60 seconds, etc.).
[0205] Heart rate cycle = lower detection limit * a Formula (3)
[0206] In the above formula (3), the heart rate cycle can be the product of the detection limit and the constant a, and the constant a is a positive number greater than 1.
[0207] It is understood that the embodiments described here are only three examples. In other embodiments, the electronic device 100 may also determine the heartbeat cycle of the communication connection 2 in a different manner than the embodiments described above. This application does not limit this.
[0208] It should be noted that steps S502 to S508 are repeatable steps. In some embodiments, the electronic device 100 can update the heartbeat period of the communication connection 2 in the same way each time step S502 is executed, for example, by updating the heartbeat period of the communication connection 2 in the way shown in formula (1) above. In other embodiments, the electronic device 100 can also update the heartbeat period of the communication connection 2 in a different way each time step S502 is executed, for example, by updating the heartbeat period of the communication connection 2 in the way shown in formula (3) the first time step S502 is executed, and by updating the heartbeat period of the communication connection 2 in the way shown in formula (1) the second time step S502 is executed, etc. It is understood that the embodiments here are only illustrative examples, and the way the heartbeat period of the communication connection 2 is updated each time step S502 is executed can be the same or different. This application does not limit this.
[0209] S503. Electronic device 100 determines the next heartbeat time based on the heartbeat cycle of communication connection 2.
[0210] exist Figure 5 In the illustrated embodiment, the next heartbeat time refers to the next time the heartbeat detection message is sent.
[0211] Electronic device 100 can determine the next heartbeat time based on the following formula (4).
[0212] The next heartbeat time = heartbeat cycle + previous heartbeat time (Formula 4)
[0213] In the above formula (4), the time of the next heartbeat can be determined based on the heartbeat cycle and the time of the previous heartbeat.
[0214] It should be noted that if the next heartbeat is the first heartbeat, then the time of the previous heartbeat can be replaced by the time of the establishment of communication connection 2.
[0215] S504. When the next heartbeat moment arrives, electronic device 100 sends a heartbeat detection message through communication connection 2.
[0216] The specific content of the heartbeat detection message can be found in the relevant descriptions in the embodiments shown in Table 1 above.
[0217] In some embodiments, the heartbeat detection message may further include heartbeat time information (e.g., the next heartbeat cycle), which is used to determine the next heartbeat time after the current heartbeat time. This application does not limit this, but for details, please refer to the following. Figure 8 The relevant descriptions in the illustrated embodiments will not be detailed here.
[0218] S505. Electronic device 100 determines whether communication connection 2 is disconnected.
[0219] If communication connection 2 remains open, electronic device 100 can receive a response message from server 300 in response to the probe heartbeat message. In some embodiments, the response message may also carry a sequence number. This sequence number can be used to indicate the transmission order of the probe heartbeat messages corresponding to the response message. Electronic device 100 can determine whether communication connection 2 remains open based on whether it has received a response message corresponding to the probe heartbeat message.
[0220] If communication connection 2 is disconnected, it indicates that the current heartbeat cycle may be longer than the timeout period.
[0221] If communication connection 2 is not disconnected, it indicates that the current heartbeat cycle is less than or equal to the timeout period.
[0222] When electronic device 100 determines that communication connection 2 is disconnected, electronic device 100 may perform the following step S506.
[0223] When electronic device 100 determines that communication connection 2 is not disconnected, electronic device 100 may perform the following step S507.
[0224] S506. Electronic device 100 updates the detection limit of the detection range and re-establishes a communication connection with server 300.
[0225] If communication connection 2 is disconnected, it indicates that the current heartbeat cycle exceeds the timeout period of electronic device 200. In this case, the current heartbeat cycle can be determined as the upper limit of the detection range.
[0226] After performing step S506, the electronic device 100 may perform the following step S508.
[0227] S507. Electronic Equipment 100 updates the lower limit of the detection range.
[0228] If communication connection 2 is not disconnected, it indicates that the current heartbeat cycle is less than or equal to the timeout period of electronic device 200. In this case, the current heartbeat cycle can be determined as the lower limit of the detection range.
[0229] According to the information regarding timeout periods, if the heartbeat period of a communication connection is equal to the timeout period, then each heartbeat message sent on that connection may or may not be sent successfully. To prevent the communication connection from being disconnected, the heartbeat period of the communication connection should be less than the timeout period. It should be noted that if communication connection 2 is not disconnected, the current heartbeat period may be equal to the timeout period.
[0230] In some embodiments, to avoid the heartbeat cycle 2 being equal to the timeout time, the electronic device 100 may subtract a constant (e.g., 10 seconds, 5 seconds, etc.) from the heartbeat cycle and update the difference between the heartbeat cycle and the constant as the lower limit of the detection range. In this way, by introducing a fixed error, the detected heartbeat cycle 2 being equal to the timeout time can be avoided, improving the stability of the detection results.
[0231] After performing step S507, the electronic device 100 may perform the following step S508.
[0232] S508. Electronic device 100 determines whether the stop condition is met.
[0233] The stopping conditions may include, but are not limited to, any one or more of the following: the difference between the upper and lower detection limits is less than a preset value, the detection time is greater than a preset duration, the number of updates to the detection interval is greater than a preset number, etc.
[0234] If the electronic device 100 determines that the stopping condition is met, the electronic device 100 may execute the following step S509.
[0235] If the electronic device 100 determines that the stopping condition is not met, the electronic device 100 can re-execute the above step S502.
[0236] S509. Electronic device 100 determines heartbeat cycle 2 based on detection interval.
[0237] In some embodiments, the electronic device 100 may determine the lower limit of the current detection range as a heartbeat cycle of 2.
[0238] Understandable Figure 5 The illustrated embodiment is merely an example; in other embodiments, the electronic device 100 may also employ the same... Figure 5 The different methods used in the illustrated embodiments to determine the heartbeat cycle 2 are not limited herein.
[0239] It should be noted that if multiple probe connections are established between electronic device 100 and server 300, electronic device 100 can use different heartbeat cycle update methods on different probe connections, and determine the heartbeat cycle 2 based on the probe results of these multiple probe connections. For specific methods, please refer to the following... Figure 6 The relevant details in the illustrated embodiments will not be described in detail here.
[0240] S404. Electronic device 100 disconnects from communication connection with server 300 2.
[0241] It should be noted that after executing step S403, the electronic device 100 may execute steps S404 and S405 simultaneously, or it may execute step S404 first and then step S405, or execute step S405 first and then step S404. This application does not limit the execution order of steps S404 and S405.
[0242] After determining the heartbeat cycle 2, the electronic device 100 can disconnect the communication connection 2.
[0243] In some embodiments, if the probe connection includes multiple communication connections, the electronic device 100 may disconnect all probe connections after the heartbeat cycle 2 is determined.
[0244] S405. Electronic device 100 sends a service heartbeat message to server 300 based on heartbeat cycle 2 via communication connection 1.
[0245] After determining the heartbeat cycle 2, the electronic device 100 can reset the heartbeat cycle of the communication connection 1 to the heartbeat cycle 2.
[0246] In this way, electronic device 100 can maintain communication connection 1 based on heartbeat cycle 2, reducing power consumption caused by sending heartbeat messages. Moreover, during the detection of heartbeat cycle 2, communication connection 1 is always maintained, and service data is transmitted on communication connection 1, which can avoid interruption of service data during the detection process.
[0247] In one possible implementation, after establishing communication connection 1, electronic device 100 can continuously update the heartbeat cycle of communication connection 1 based on the detection results during the detection heartbeat cycle 2, and send service heartbeat messages based on the updated heartbeat cycle.
[0248] For example, Figure 6 This illustration shows a schematic diagram of the transmission process of service heartbeat messages by electronic device 100 on communication connection 1 during the detection heartbeat cycle 2, as provided in an embodiment of this application.
[0249] like Figure 6 As shown, during the detection heartbeat cycle 2, the process of electronic device 100 sending service heartbeat messages on communication connection 1 may include the following steps:
[0250] S601. Electronic device 100 updates the maximum heartbeat cycle Tmax based on the detection results on communication connection 2.
[0251] During the process of detecting heartbeat cycle 2 based on communication connection 2, electronic device 100 can detect one or more available heartbeat cycles. An available heartbeat cycle refers to a heartbeat cycle that can maintain the communication connection between electronic device 100 and server 300, that is, the heartbeat cycle is less than the timeout period.
[0252] In some embodiments, the electronic device 100 may store a maximum heartbeat cycle Tmax, which refers to the heartbeat cycle with the largest value among all the available heartbeat cycles detected.
[0253] In some embodiments, the electronic device 100 may store a heartbeat cycle table, which may include a maximum heartbeat cycle Tmax. The maximum heartbeat cycle Tmax may be the largest available heartbeat cycle currently detected.
[0254] For example, Table 2 shows a heart rate cycle table stored in an electronic device 100 according to an embodiment of this application.
[0255] Table 2
[0256] Maximum heart rate cycle Tmax = T1 Detection limit T2 Detection lower limit T1
[0257] As shown in Table 2, the heart rate cycle table stored in the electronic device 100 may include the maximum heart rate cycle, and optionally, it may also include an upper detection limit and a lower detection limit, which can be as described above. Figure 5 The two ends of the detection interval in the illustrated embodiment. According to Table 2, the maximum heartbeat period Tmax can be T1, the upper limit of detection can be T2, and the lower limit of detection can be T1.
[0258] It is understood that the embodiments shown in Table 2 are only examples. In the embodiments of this application, the heart rate cycle table may also include more, less or different content than the above embodiments, and this application does not limit it.
[0259] In one possible implementation, when the electronic device 100 detects a new available heartbeat cycle and the value of the available heartbeat cycle is greater than the currently stored maximum heartbeat cycle Tmax, the electronic device 100 can update the value of the maximum heartbeat cycle Tmax, that is, determine the value of Tmax as the new available heartbeat cycle.
[0260] For example, if electronic device 100 determines through communication connection 2 that heartbeat period T3 is an available heartbeat period and T3 is greater than T1, electronic device 100 can update the heartbeat period table shown in Table 2 above to the heartbeat period table shown in Table 3 below.
[0261] Table 3
[0262] Maximum heart rate cycle Tmax = T3 Detection limit T2 Detection lower limit T3
[0263] As shown in Table 3, the heartbeat cycle table stored in the electronic device 100 may include a maximum heartbeat cycle, and optionally, an upper detection limit and a lower detection limit. According to Table 3, the maximum heartbeat cycle Tmax can be T3, the upper detection limit can be T2, and the lower detection limit can be T3. That is, the values of the maximum heartbeat cycle and the lower detection limit in the heartbeat cycle table can both be updated to T3.
[0264] It is understood that the embodiments shown in Table 3 are only examples. In the embodiments of this application, the heart rate cycle table may also include more, less or different content than the above embodiments, and this application does not limit it.
[0265] S602. Electronic device 100 determines the next heartbeat time of communication connection 1 based on the heartbeat cycle of communication connection 1.
[0266] exist Figure 6 In the illustrated embodiment, the next heartbeat time refers to the time when the electronic device 100 will next send a service heartbeat message through communication connection 1.
[0267] Electronic device 100 can determine the next heartbeat time based on the heartbeat cycle of communication connection 1 and the time of the previous heartbeat. It should be noted that if the next heartbeat is the first heartbeat, electronic device 100 can determine the next heartbeat time based on the heartbeat cycle of communication connection 1 and the time when communication connection 1 was established.
[0268] After performing step S602, the electronic device 100 may perform the following step S603.
[0269] S603. When the next heartbeat moment arrives, the electronic device 100 determines whether the maximum heartbeat period Tmax is greater than the heartbeat period of the communication connection 1.
[0270] If the maximum heartbeat period Tmax is greater than the heartbeat period of communication connection 1, then electronic device 100 can perform the following step S604 to update the heartbeat period of communication connection 1.
[0271] If the maximum heartbeat period Tmax is less than or equal to the heartbeat period of communication connection 1, then electronic device 100 can perform the following step S605.
[0272] S604. Electronic device 100 determines the heartbeat period of communication connection 1 as the maximum heartbeat period Tmax.
[0273] After performing step S604, the electronic device 100 can perform the above-mentioned step S602.
[0274] S605. Electronic device 100 sends a service heartbeat message to server 300 through communication connection 1.
[0275] After performing step S605, the electronic device 100 can perform the above-mentioned step S602.
[0276] Understandable Figure 6 The embodiments shown are merely illustrative. During the detection of the heartbeat cycle 2, the electronic device 100 can update the heartbeat cycle of the service connection based on the detection results on the detection connection. In this application embodiment, the detection connection may also include more communication connections than in the above embodiments, and the method of updating the heartbeat cycle on the service connection may also be different from that in the above embodiments. This application does not limit this.
[0277] In this way, during the detection of heartbeat cycle 2, electronic device 100 can update the heartbeat cycle of communication connection 1 based on the detection results on communication connection 2, thereby reducing power consumption and improving the battery life of electronic device 100.
[0278] In another possible implementation, the electronic device 100 may also update the heartbeat period of communication connection 1 synchronously after updating the maximum heartbeat period Tmax based on the detection results on communication connection 2, and send a service heartbeat message on communication connection 1 based on the updated heartbeat period. This application does not limit this.
[0279] In one possible implementation, during the detection heartbeat cycle 2 based on communication connection 2, if the difference between the next transmission time of the service heartbeat message on communication connection 1 and the next transmission time of the detection heartbeat message on communication connection 2 is within a preset time interval (e.g., less than or equal to 5 seconds, less than or equal to 10 seconds, etc.), then the electronic device 100 can control communication connection 1 and communication connection 2 to send service heartbeat messages and detection heartbeat messages at the same time.
[0280] In this way, if the electronic device 100 is in a low-power state (or a screen-off state), it only needs to be woken up once to complete the sending of the service heartbeat message and the probe heartbeat message, which reduces the number of times the electronic device 100 needs to be woken up, reduces the power consumption of the electronic device 100, and thus improves the battery life of the electronic device 100.
[0281] The following describes a communication method provided by an embodiment of this application, with specific examples.
[0282] like Figure 7As shown, the times when electronic device 100 sends multiple service heartbeat messages on communication connection 1 can be displayed in a one-dimensional coordinate system OX1, and the times when electronic device 100 sends multiple detection heartbeat messages on communication connection 2 can be displayed in a one-dimensional coordinate system OX2. The one-dimensional coordinate system OX1 may include a horizontal axis X1, which can represent time; the one-dimensional coordinate system OX2 may include a horizontal axis X2, which can represent time, and the times on the horizontal axis X1 and the horizontal axis X2 correspond one-to-one.
[0283] On the horizontal axis X1, a triangle can represent the transmission of a service heartbeat message. On the horizontal axis X2, a circle can represent the establishment of communication connection 2, an empty triangle can represent the transmission of a probe heartbeat message, and a solid triangle can represent the failure of the probe heartbeat message transmission.
[0284] according to Figure 7 It can be seen that the interaction between electronic device 100 and server 300 on communication connection 1 and communication connection 2 may include the following steps:
[0285] At time t0, electronic device 100 has established a communication connection with server 300.
[0286] 2. From time t0 to time t1, electronic device 100 sends a service heartbeat message to server 300 on communication connection 1 based on heartbeat period T.
[0287] The time interval between time t0 and time t1 can be 2T.
[0288] At time t1, electronic device 100 detects that the detection conditions are met and establishes a communication connection 2 with server 300.
[0289] Communication connection 2 is a probe connection, and no service data will be transmitted on communication connection 2.
[0290] 4. From time t1 to time t2, electronic device 100 sends a heartbeat detection message to server 300 on communication connection 2 based on heartbeat cycle 2T.
[0291] The heartbeat period 2T of communication connection 2 can be determined based on the heartbeat period T of communication connection 1. The time interval between time t1 and time t2 is 2T.
[0292] At time t2, electronic device 100 sends a service heartbeat message to server 300 on communication connection 1, and at the same time, sends a probe heartbeat message to server 300 on communication connection 2.
[0293] 6. After the electronic device 100 confirms that the detection heartbeat message at time t2 has been successfully sent, it can synchronize the heartbeat cycle 2T with the communication connection 1.
[0294] 7. Electronic device 100 can determine a new heartbeat cycle (2T-x) on communication connection 1 based on the heartbeat cycle 2T synchronized on communication connection 2, where x can be a preset constant.
[0295] 8. From time t2 to time t3, electronic device 100 sends service heartbeat messages to server 300 on communication connection 1 based on the heartbeat cycle (2T-x).
[0296] 9. From time t2 to time t3, electronic device 100 sends service heartbeat messages to server 300 on communication connection 2 based on heartbeat cycle (4T-2x).
[0297] The heart rate cycle (4T-2x) can be determined based on the heart rate cycle 2T. The time interval between time t2 and time t3 can be (4T-2x).
[0298] In some embodiments, the electronic device 100 may also determine the heartbeat period 4T based on the previous heartbeat period 2T of the communication connection 2. Since time t3 is the time when the service heartbeat message is sent on the communication connection 1, and the difference between time t3 and the time when the next detection heartbeat message of the communication connection 2 is sent is within a preset time interval (e.g., less than 60 seconds, less than 30 seconds), the electronic device 100 may adjust the time when the next detection heartbeat message of the communication connection 2 is sent to time t3.
[0299] At time 10.t3, electronic device 100 sends a service heartbeat message to server 300 on communication connection 1, and at the same time, sends a probe heartbeat message to server 300 on communication connection 2.
[0300] At time t31, after determining that the detection heartbeat message at time t3 failed to be sent, electronic device 100 can re-establish communication connection 2 with server 300 and change the heartbeat cycle of communication connection 2 to the heartbeat cycle (3T-x).
[0301] Time t31 is later than time t3. The heartbeat period (3T-x) can be determined based on the heartbeat period 2T and the heartbeat period (4T-x).
[0302] 12. From time t3 to time t4, electronic device 100 can continue to send service heartbeat messages to server 300 on communication connection 1 based on heartbeat cycle (2T-x).
[0303] At time 13.t4, electronic device 100 sends a heartbeat detection message to server 300 via communication connection 2.
[0304] The time interval between t31 and t4 is (3T-x).
[0305] 14. After the electronic device 100 confirms that the detection heartbeat message at time t2 has been successfully sent, it can synchronize the heartbeat cycle (3T-x) to the communication connection 1.
[0306] 15. Electronic device 100 can determine a new heartbeat cycle (3T-2x) on communication connection 1 based on the heartbeat cycle (3T-x) synchronized on communication connection 2.
[0307] 16. Electronic device 100 detects that the stop condition is met and disconnects communication connection 2.
[0308] After time 17.t4, electronic device 100 can send service heartbeat messages to server 300 on communication connection 1 based on heartbeat cycle (3T-2x).
[0309] In this way, the electronic device 100 can maintain the communication connection 1 used for transmitting business data during the detection heartbeat cycle 2, and determine the heartbeat cycle 2 through the detection connection such as the communication connection 2, which can avoid interruption of business data and reduce the power consumption of the electronic device 100.
[0310] Figure 8 This illustration shows a flowchart of the execution of the business server 310 and the detection server 320 in the server 300 during the detection heartbeat cycle 2, according to an embodiment of this application.
[0311] like Figure 8 As shown, during the detection of heartbeat cycle 2, the specific execution process of server 300 may include the following steps:
[0312] S801, the business server 310 establishes a communication connection with the electronic device 100.
[0313] In some embodiments, the specific methods by which the business server 310 establishes a communication connection 1 with the electronic device 100 and the detection server 320 establishes a communication connection 2 with the electronic device 100 can refer to the method of establishing a TCP long connection, which will not be described in detail here.
[0314] S802. The service server 310 receives the service heartbeat message sent by the electronic device 100 through the communication connection 1.
[0315] Step S802 is a repeatable step.
[0316] As can be seen from the above embodiments, the electronic device 100 can send service heartbeat messages to the service server 310 based on the heartbeat cycle (e.g., heartbeat cycle 1) of the communication connection 1. Therefore, the service server 310 can receive the service heartbeat messages periodically sent by the electronic device 100 on the communication connection 1.
[0317] In some embodiments, the service server 310 may respond to the service heartbeat message by sending a response message to the electronic device 100 through the communication connection 1. The response message is used to notify the electronic device 100 that the service heartbeat message was successfully sent.
[0318] In other embodiments, the service server 310 may also receive a service data acquisition request sent by the electronic device 100 through the communication connection 1. The service data acquisition request is used to request the service server 310 to send service data to the electronic device 100. In response to the service data acquisition request, the service server 310 can send service data to the electronic device 100 through the communication connection 1.
[0319] S803. The detection server 320 establishes a communication connection with the electronic device 100 2, and obtains the heartbeat time information sent by the electronic device 100. The heartbeat time information is used to determine the next time the detection server 320 receives the detection heartbeat message.
[0320] In some embodiments, heart rate time information may include the next heart rate cycle and / or the time of the next heartbeat. Optionally, heart rate time information may also include the time of the current heartbeat.
[0321] In some embodiments, the next heartbeat cycle and / or the next heartbeat time can be determined based on the current heartbeat cycle and a preset heartbeat cycle algorithm. For example, the next heartbeat cycle can be the sum of the current heartbeat cycle and the step size, or the next heartbeat cycle can be the product of the current heartbeat cycle and a constant, or the next heartbeat cycle can be the average of the current heartbeat cycle and the detection upper limit, etc. Specific calculation methods can be found above. Figure 5 The relevant descriptions in steps S502 and S503 shown will not be repeated here.
[0322] S804. The detection server 320 determines the reception time based on the newly received heartbeat time information.
[0323] The reception time refers to the time when the detection server 320 receives the detection heartbeat message again through communication connection 2.
[0324] In some embodiments, the heartbeat time information may include the next heartbeat cycle. In this case, the detection server 320 can determine the reception time based on the next heartbeat cycle. For example, the next heartbeat cycle and the reception time satisfy the relationship shown in the following formulas (5) and (6).
[0325] Reception time = Next heartbeat time + Transmission time (Formula 5)
[0326] The time of the next heartbeat = the time of the next heartbeat cycle + the time of the current heartbeat (Formula 6)
[0327] According to formulas (5) and (6) above, the receiving time can be the sum of the next heartbeat time and the transmission time, where the transmission time can be a preset constant, such as 20 seconds, 10 seconds, etc. The next heartbeat time can be the sum of the current heartbeat time and the next heartbeat cycle. In some embodiments, the heartbeat time information may include the current heartbeat time. In other embodiments, the current heartbeat time may also be determined based on the heartbeat time information carried in the previous heartbeat detection message.
[0328] For example, the relationship between the next heartbeat cycle and the receiving time satisfies the following formula (7).
[0329] Reception time = Previous reception time + Next heartbeat cycle (Formula 7)
[0330] According to formulas (5) and (6) above, the receiving time can also be the sum of the previous receiving time and the next heartbeat cycle. Here, the current receiving time refers to the moment when the heartbeat time information is received that is closest to the current time.
[0331] In other embodiments, the heartbeat time information may include the next heartbeat time, in which case the detection server 320 may determine the receiving time based on the next heartbeat time using the above formula (5).
[0332] It is understood that the embodiments described here are merely examples. In the embodiments of this application, the detection server 320 may also calculate the receiving time in a different manner from the above embodiments based on the heartbeat time information. This application does not limit this.
[0333] S805. When the receiving time arrives, the probe server 320 determines whether it has received the probe heartbeat message.
[0334] When the receiving time arrives, the detection server 320 can determine whether it has received the detection heartbeat message sent by the electronic device 100 through the communication connection 2 within a preset time period. The preset time period can be the period from the receipt of the heartbeat time information used to calculate the receiving time until the arrival of the receiving time.
[0335] If the detection server 320 receives the detection heartbeat message, it indicates that the communication connection 2 can be maintained normally. At this time, the detection server 320 can perform the following step S806.
[0336] If the detection server 320 does not receive the detection heartbeat message, it indicates that the communication connection 2 may not be maintained, and the detection server 320 can perform the following step S807.
[0337] S806. The detection server 320 determines new heartbeat time information based on the newly received detection heartbeat message.
[0338] The heartbeat detection message can carry heartbeat timing information. For details regarding the heartbeat timing information, please refer to the relevant description in step S803 above.
[0339] It should be noted that the heartbeat time information received each time is used to determine the next time the probe server 320 receives the probe heartbeat message; that is, the heartbeat time information received each time is different.
[0340] After executing step S806, the probe server 320 can execute the above step S804.
[0341] S807. Detection server 320 disconnects communication connection 2.
[0342] After disconnecting communication connection 2, the probe server 320 can re-execute the above step S803.
[0343] In this way, the probe server 320 can determine whether to disconnect the communication connection based on the heartbeat time information carried in the probe heartbeat message, thereby reducing the power consumption of the probe server 320.
[0344] Understandable, Figure 8 The illustrated embodiment is merely an example. In some embodiments, during the detection of heartbeat cycle 2, server 300 may perform more, fewer, or different steps than those described in the above embodiment, and this application does not limit the scope of the embodiment. Furthermore, if no detection server 320 is configured in server 300, the service server 310 in server 300 may also perform the above-described steps. Figure 8 The steps performed by the detection server 320 in the illustrated embodiment are not limited here.
[0345] In some embodiments, when the detection conditions are met, electronic device 100 can establish multiple detection connections (e.g., communication connection 2 and communication connection 3) with server 300 through electronic device 200. In this case, electronic device 100 can use different heartbeat cycle calculation methods on different detection connections, and update the upper and lower limits of the detection interval based on the detection results on multiple detection connections, thereby determining heartbeat cycle 2.
[0346] In this way, the electronic device 100 can determine the heartbeat cycle 2 through multiple detection connections, thereby improving the detection speed of the heartbeat cycle 2.
[0347] The functional modules of a communication system 10 provided in the embodiments of this application are described below.
[0348] Figure 9 This is a schematic diagram of the functional modules of a communication system 10 provided in an embodiment of this application.
[0349] like Figure 9 As shown, the communication system 10 may include electronic device 100, electronic device 200, and server 300. Electronic device 100 may include a communication module 911, a service module 912, and a heartbeat control module 913. Electronic device 200 may include an intranet communication module 921, a network address translation module 922, and a public network communication module 923. Server 300 may include a service module 931 and a detection service module 932.
[0350] In electronic device 100, communication module 911 can establish communication connections with other devices. For example, it can establish communication connection 1 with server 300 via electronic device 200, and communication connection 2 with server 300 via electronic device 200, etc. Communication module 911 can communicate with other devices. In some embodiments, communication module 911 can send service heartbeat messages on communication connection 1 and probe heartbeat messages on communication connection 2, etc. In some embodiments, communication module 911 can also receive service data through communication connection 1 and send the received service data to service module 912. In other embodiments, communication module 911 can also receive service data acquisition requests sent by service module 912 and send the service data acquisition requests to server 300 through communication connection 1.
[0351] The service module 912 can send a service data acquisition request to the communication module 911. The service data acquisition request is used to request the server 300 to send service data through communication connection 1. The service module 912 can also receive service data sent by the communication module 911 and perform corresponding services based on the service data.
[0352] The heartbeat control module 913 can control the transmission of heartbeat messages on multiple communication connections. In some embodiments, the heartbeat control module 913 can set the transmission time of each heartbeat message on communication connection 1, and can also set the transmission time of each heartbeat message on communication connection 2. When the transmission time of the service heartbeat message arrives, the heartbeat control module 913 can control the communication module 911 to send the service heartbeat message through communication connection 1. When the transmission time of the probe heartbeat message arrives, the heartbeat control module 913 can control the communication module 911 to send the probe heartbeat message through communication connection 2. In some embodiments, the heartbeat control module 913 can also align the transmission times of one or more service heartbeat messages and probe heartbeat messages. The specific alignment method can be referred to the relevant content in the above embodiments, and will not be repeated here.
[0353] In electronic device 200, intranet communication module 921 can establish communication connections with electronic device 100 (e.g., communication connections A1 and A2). Network address translation module 922 can translate the intranet IP address of electronic device 100 to obtain the corresponding public IP address. Public network communication module 923 can establish communication connections with server 300 based on the translated public IP address (e.g., communication connections B1 and B2).
[0354] In server 300, service module 931 can establish communication connection 1 with electronic device 100 through electronic device 200. This communication connection 1 can be used to transmit service data and service data acquisition requests. Service module 931 can receive service data acquisition requests sent by electronic device 100 through communication connection 1, and in response to the service data acquisition requests, send service data to electronic device 100 through communication connection 1.
[0355] The detection service module 932 can establish a communication connection 2 with the electronic device 100 through the electronic device 200. This communication connection 2 can be used to detect the heartbeat cycle 2. In some embodiments, the detection service module 932 can also establish multiple communication connections with the electronic device 100 through the electronic device 200, and determine the heartbeat cycle 2 based on these multiple communication connections; this application does not limit this. The detection service module 932 can receive heartbeat detection messages sent by the electronic device 100 through the communication connection 2. In some embodiments, the detection service module 932 can also send a response message to the electronic device 100 in response to the heartbeat detection message. The response message is used to notify the server 300 that the server has received the heartbeat detection message.
[0356] Understandable, Figure 9 The illustrated embodiments are merely examples. In the embodiments of this application, the communication system 10 may also include more, fewer, or different devices than those in the above embodiments, and each electronic device (or server) may also include more, fewer, or different functional modules than those in the above embodiments. This application does not impose any limitations here. Furthermore, in some embodiments, multiple functional modules in the above embodiments may be integrated into one functional module, or one functional module in the above embodiments may be divided into multiple different functional modules. This application does not impose any limitations here either.
[0357] Figure 10 A flowchart illustrating a communication method provided in an embodiment of this application is shown.
[0358] like Figure 10 As shown, the specific process of the communication method may include the following steps:
[0359] S1001. The first electronic device establishes a first connection with the server.
[0360] The first electronic device can be the electronic device 100 in the above embodiments, and the server can be the server 300 in the above embodiments. The first connection can be the communication connection 1 in the above embodiments, and the first connection is a service connection.
[0361] In one possible implementation, the server is a set of servers, including a first server and a second server; the first server is used to establish a first connection with a first electronic device, and the second server is used to establish a second connection with the first electronic device.
[0362] The first server can be the service server in the above embodiments, and the second server can be the probe server in the above embodiments. The second connection can be communication connection 2 in the above embodiments, and the second connection is a probe connection.
[0363] In this way, business services and probing services can be provided by different servers in the server set, which allows for better control over data transmission on different connections.
[0364] S1002. The first electronic device sends a first type of heartbeat message to the server based on a first cycle through the first connection.
[0365] The first cycle can be the heartbeat cycle 1 in the above embodiment.
[0366] The first type of heartbeat message can be the service heartbeat message in the above embodiments.
[0367] S1003. The first electronic device establishes a second connection with the server, the second connection being used to transmit the second type of heartbeat message.
[0368] The second connection can be communication connection 2 in the above embodiments. The second type of heartbeat message can be the detection heartbeat message in the above embodiments.
[0369] In one possible implementation, the first electronic device establishes a second connection with the server, specifically including: when a detection condition is detected, the first electronic device establishes a second connection with the server; wherein the detection condition includes any one or more of the following: the first electronic device establishes a communication connection with the server for the first time, the time since the last detection reaches a first duration, the first operation is received from the user, the first operation is used to instruct the first electronic device to determine a second period, and a detection instruction is received, the detection instruction is used to instruct the first electronic device to determine a second period.
[0370] For further details regarding the detection conditions, please refer to the above. Figure 4 The relevant descriptions in the illustrated embodiments will not be repeated here.
[0371] In this way, a detection connection (i.e., a second connection) can be established when the detection conditions are met, and a second cycle can be determined based on the detection connection.
[0372] In one possible implementation, the format of the first type of heartbeat message is the same as that of the second type of heartbeat message; or, the format of the first type of heartbeat message is different from that of the second type of heartbeat message.
[0373] In one possible implementation, the first type of heartbeat message contains more content than the second type of heartbeat message. This saves power consumption when sending the second type of heartbeat message.
[0374] In some embodiments, the format of the first type of heartbeat message and the format of the second type of heartbeat message can also refer to the relevant content in the embodiments shown in Table 1 above.
[0375] S1004. The first electronic device determines the second cycle based on the second connection.
[0376] The second cycle can be the heartbeat cycle 2 in the above embodiment.
[0377] In one possible implementation, the second cycle is longer than the first cycle.
[0378] This reduces the frequency of heartbeat messages sent on the service connection, lowers power consumption, and improves battery life.
[0379] In one possible implementation, the specific content of step S1004 can also refer to the above. Figure 5 The relevant descriptions in the illustrated embodiments will not be repeated here.
[0380] S1005. The first electronic device sends a first type of heartbeat message to the server based on a second cycle through the first connection.
[0381] It should be noted that steps S1005 and S1006 can be executed simultaneously, or steps S1005 can be executed first and then steps S1006, or steps S1006 can be executed first and then steps S1005. This application does not limit the execution order of steps S1005 and S1006.
[0382] S1006. The first electronic device disconnects the second connection.
[0383] In this way, service data can be transmitted on the first connection (i.e., the service connection), and the heartbeat cycle can be detected on the second connection (i.e., the probe connection), thus avoiding interruption of service data transmission during the probe process.
[0384] In one possible implementation, the moment when the first electronic device establishes a second connection with the server is the first moment; determining a second period based on the second connection specifically includes: at the second moment, sending a first message to the server through the second connection, the first message being a second type of heartbeat message, the second moment being later than the first moment; receiving a first response, the first response being the server's response to the first message sent through the second connection; when a stopping condition is detected, determining the second period based on the time interval between the first moment and the second moment.
[0385] In one possible implementation, the second period is the time interval between the first and second moments, or the second period is the difference between the time interval between the first and second moments and the fourth constant.
[0386] For example, refer to the above. Figure 7 In the illustrated embodiment, the first time point can be time t31, and the second time point can be time t4. The second period can be the time interval between time t31 and time t4, or it can be the difference between the time interval between time t31 and time t4 and a preset fourth constant (e.g., x).
[0387] In this way, when the stopping condition is detected, the second period can be determined based on the heartbeat period corresponding to the most recent successfully sent heartbeat message on the second connection.
[0388] In one possible implementation, the time interval between the first and second moments is: the product of the first period and the first constant, where the first constant is a positive number greater than 1; or, the sum of the first period and the second constant, where the second constant is a positive number; or, the average of the first period and the third constant, where the third constant is greater than the first period.
[0389] For example, the first constant can be the constant a in the above formula (3), the second constant can be the step size in the above formula (2), and the third constant can be the detection upper limit in the above formula (1).
[0390] In this way, the next heartbeat cycle on the second connection can be determined based on the first cycle.
[0391] In one possible implementation, the method further includes: before the first moment, sending a second message to the server via the second connection, the second message being a second type of heartbeat message; detecting that the second connection is broken; and at the first moment, the first electronic device re-establishing the second connection with the server.
[0392] For example, refer to the above. Figure 7 In the embodiment shown, the first time point can be time t31, and the second message can be the heartbeat detection message sent at time t2.
[0393] In this way, after the second connection is broken, the second connection can be re-established, and the second cycle can be determined based on the re-established second connection.
[0394] In one possible implementation, determining the second period based on the second connection specifically includes: at a third time, sending a third message to the server through the second connection, the third message being a second type of heartbeat message; receiving a third response, the third response being the server's response to the third message sent through the second connection; at a fourth time, sending a fourth message to the server through the second connection, the fourth message being a second type of heartbeat message, the fourth time being later than the third time; receiving a fourth response, the fourth response being the server's response to the fourth message sent through the second connection; and when a stopping condition is detected, determining the second period based on the time interval between the third time and the fourth time.
[0395] In one possible implementation, the second period is the time interval between the third and fourth time points, or the difference between the time interval between the third and fourth time points and the fourth constant.
[0396] In this way, when the stopping condition is detected, the second period can be determined based on the heartbeat period corresponding to the most recent successfully sent heartbeat message on the second connection.
[0397] In one possible implementation, the moment when the first electronic device establishes a second connection with the server is a first moment, the time interval between the first moment and the third moment is a first time interval, and the time interval between the third moment and the fourth moment is a second time interval; the first time interval is less than the second time interval; the method further includes: before the first moment, sending a second message to the server through the second connection, the first message being a second type of heartbeat message; detecting that the second connection is broken; and at the first moment, the first electronic device re-establishes a second connection with the server.
[0398] In this way, after the second connection is broken, the second connection can be re-established, and the second cycle can be determined based on the re-established second connection.
[0399] In one possible implementation, the second time interval is: the product of the first time interval and a first constant, where the first constant is a positive number greater than 1; or, the sum of the first time interval and a second constant, where the second constant is a positive number; or, the average of the first time interval and a third constant, where the third constant is greater than the first time interval.
[0400] In this way, the next heartbeat cycle of the second connection can be determined based on the current heartbeat cycle of the second connection.
[0401] In one possible implementation, before determining the second period based on the second connection, the method further includes: after receiving the third response, sending a first type of heartbeat message to the server based on the third period through the first connection, wherein the third period is the time interval between the first moment and the third moment.
[0402] In this way, during the determination of the second cycle, the heartbeat cycle of the first connection can be updated in real time based on the detection results on the second connection.
[0403] In one possible implementation, before determining the second period based on the second connection, the method further includes: after receiving the third response, sending a first type of heartbeat message to the server via the first connection based on the third period, wherein the third period is the difference between the time interval between the first moment and the third moment and a fourth constant.
[0404] In this way, during the determination of the second cycle, the heartbeat cycle of the first connection can be updated in real time based on the detection results on the second connection. Moreover, the heartbeat cycle of the first connection can be prevented from being equal to the timeout period by introducing a fixed error (i.e., a fourth constant).
[0405] In one possible implementation, before the third time point, the method further includes: at the fifth time point, sending a fifth message to the server via the second connection, the fifth message being a second type of heartbeat message; receiving a fifth response, the fifth response being the server's response to the fifth message sent via the second connection; wherein the time interval between the fifth time point and the third time point is the third time interval, the time interval between the third time point and the fourth time point is the second time interval, and the third time interval is less than the second time interval.
[0406] In this way, when the stopping condition is detected, the second period can be determined based on the heartbeat period corresponding to the most recent successfully sent heartbeat message on the second connection.
[0407] In one possible implementation, the second time interval is: the product of the third time interval and the first constant, where the first constant is a positive number greater than 1; or, the sum of the third time interval and the second constant, where the second constant is a positive number; or, the average of the third time interval and the third constant, where the third constant is greater than the third time interval.
[0408] In this way, the next heartbeat cycle of the second connection can be determined based on the current heartbeat cycle of the second connection.
[0409] In one possible implementation, before determining the second period based on the second connection, the method further includes: after receiving the third response, sending a first type of heartbeat message to the server based on the fourth period through the first connection; the fourth period is the time interval between the fifth time and the third time, or the fourth period is the difference between the time interval between the fifth time and the third time and a fourth constant.
[0410] In this way, during the determination of the second cycle, the heartbeat cycle of the first connection can be updated in real time based on the detection results on the second connection. Furthermore, a fixed error (i.e., a fourth constant) can be introduced to prevent the heartbeat cycle of the first connection from coinciding with the timeout period.
[0411] In one possible implementation, the moment when the first electronic device establishes a second connection with the server is designated as the first moment; determining the second period based on the second connection specifically includes: at a sixth moment, sending a sixth message to the server through the second connection, the sixth message being a type 2 heartbeat message, the sixth moment being later than the first moment; receiving a sixth response, the sixth response being the server's response to the sixth message sent through the second connection; at a seventh moment, sending a seventh message to the server through the second connection, the seventh message being a type 2 heartbeat message, the seventh moment being later than the sixth moment; detecting that the second connection is broken; and when a stopping condition is detected, determining the second period based on the time interval between the first moment and the sixth moment.
[0412] In one possible implementation, the second period is the time interval between the first time point and the sixth time point, or the second period is the difference between the time interval between the first time point and the sixth time point and the fourth constant.
[0413] In this way, when the stopping condition is detected, the second period can be determined based on the heartbeat period corresponding to the most recent successfully sent heartbeat message on the second connection.
[0414] In one possible implementation, determining the second period based on the second connection specifically includes: at time eight, sending an eighth message to the server via the second connection, the eighth message being a type two heartbeat message; receiving an eighth response, the eighth response being the server's response to the eighth message sent via the second connection; at time nine, sending a ninth message to the server via the second connection, the ninth message being a type two heartbeat message, time nine being later than time eight; receiving a ninth response, the ninth response being the server's response to the ninth message sent via the second connection; at time ten, sending a tenth message to the server via the second connection, the tenth message being a type two heartbeat message, time ten being later than time nine; detecting that the second connection is broken; and when a stopping condition is detected, determining the second period based on the time interval between time eight and time nine.
[0415] In one possible implementation, the second period is the time interval between the eighth and ninth times, or the second period is the difference between the time interval between the eighth and ninth times and the fourth constant.
[0416] In this way, when the stopping condition is detected, the second period can be determined based on the heartbeat period corresponding to the most recent successfully sent heartbeat message on the second connection.
[0417] In one possible implementation, the stopping conditions include, but are not limited to, any one or more of the following: the probe duration reaches a second duration, the number of times a second type of heartbeat message is sent through the second connection reaches a first count, and the number of times the second connection is established reaches a second count.
[0418] For other relevant information on stopping conditions, please refer to the above. Figure 5 The relevant descriptions in the illustrated embodiments will not be repeated here.
[0419] In one possible implementation, after the first electronic device establishes a second connection with the server, the method further includes: at an eleventh moment, sending a first type of heartbeat message to the server through the first connection; at a twelfth moment, sending an eleventh message to the server through the second connection, the eleventh message being a second type of heartbeat message, the twelfth moment being later than the eleventh moment, and the time interval between the eleventh moment and the twelfth moment being a fourth time interval; at the twelfth moment, sending a first type of heartbeat message to the server through the first connection, the absolute value of the difference between the fourth time interval and the first period being less than a first threshold.
[0420] In this way, by aligning the sending times of heartbeat messages on the first and second connections, the number of times the first electronic device needs to be woken up can be reduced, thereby lowering the power consumption of the first electronic device.
[0421] In one possible implementation, the first electronic device establishes a first connection with the server, specifically including: the first electronic device establishes a first connection with the server through a second electronic device; the first electronic device establishes a second connection with the server, specifically including: the first electronic device establishes a second connection with the server through a second electronic device.
[0422] In this way, the first electronic device can establish a communication connection with the server through the second electronic device.
[0423] In one possible implementation, the method further includes: establishing a third connection between the first electronic device and the server; determining a second period based on the second connection, specifically including: determining the second period based on the second connection and the third connection.
[0424] The third connection is used to transmit the second type of heartbeat message.
[0425] In this way, the second cycle can be determined based on multiple probe connections.
[0426] The various embodiments of this application can be combined arbitrarily to achieve different technical effects.
[0427] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk (SSD)).
[0428] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM or random access memory (RAM), magnetic disks, or optical disks.
[0429] In summary, the above description is merely an embodiment of the technical solution of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made according to the disclosure of the present invention should be included within the scope of protection of the present invention.
Claims
1. A communication method, characterized in that, Applied to a first electronic device, the method includes: The first electronic device establishes a first connection with the server; The first type of heartbeat message is sent to the server through the first connection based on a first cycle; The first electronic device establishes a second connection with the server, the second connection being used to transmit a second type of heartbeat message; The second cycle is determined based on the second connection; The first type of heartbeat message is sent to the server based on the second period through the first connection; Disconnect the second connection.
2. The method according to claim 1, characterized in that, The second period is longer than the first period.
3. The method according to claim 1 or 2, characterized in that, The first electronic device establishes a second connection with the server, specifically including: When the detection conditions are met, the first electronic device establishes the second connection with the server; wherein the detection conditions include any one or more of the following: the first electronic device establishes a communication connection with the server for the first time, the time since the last detection reaches a first duration, the first operation is received from the user, the first operation is used to instruct the first electronic device to determine the second period, and a detection instruction is received, the detection instruction is used to instruct the first electronic device to determine the second period.
4. The method according to claim 1 or 2, characterized in that, The format of the first type of heartbeat message is the same as that of the second type of heartbeat message; or, the format of the first type of heartbeat message is different from that of the second type of heartbeat message.
5. The method according to claim 1 or 2, characterized in that, The moment when the first electronic device establishes the second connection with the server is the first moment; The determination of the second period based on the second connection specifically includes: At the second moment, a first message is sent to the server through the second connection. The first message is a heartbeat message of the second type. The second moment is later than the first moment. A first response is received, wherein the first response is the server's response to the first message sent through the second connection; When the stopping condition is detected, the second period is determined based on the time interval between the first time and the second time.
6. The method according to claim 5, characterized in that, The time interval between the first time point and the second time point is: The product of the first period and the first constant, where the first constant is a positive number greater than 1; or, The sum of the first period and the second constant, where the second constant is a positive number; or, The average of the first period and the third constant, wherein the third constant is greater than the first period.
7. The method according to claim 5, characterized in that, The method further includes: Before the first moment, a second message is sent to the server through the second connection, the second message being a heartbeat message of the second type; The second connection was detected to be disconnected; At the first moment, the first electronic device re-establishes the second connection with the server.
8. The method according to claim 1, characterized in that, The determination of the second period based on the second connection specifically includes: At the third moment, a third message is sent to the server through the second connection, and the third message is a heartbeat message of the second type. A third response is received, wherein the third response is the server's response to the third message sent through the second connection; At the fourth moment, a fourth message is sent to the server through the second connection. The fourth message is a heartbeat message of the second type. The fourth moment is later than the third moment. A fourth response is received, which is the server's response to the fourth message sent through the second connection; When the stopping condition is detected, the second period is determined based on the time interval between the third time and the fourth time.
9. The method according to claim 8, characterized in that, The moment when the first electronic device establishes the second connection with the server is a first moment, the time interval between the first moment and the third moment is a first time interval, and the time interval between the third moment and the fourth moment is a second time interval; the first time interval is less than the second time interval; the method further includes: Before the first moment, a second message is sent to the server through the second connection, and the first message is a second type of heartbeat message; The second connection was detected to be disconnected; At the first moment, the first electronic device re-establishes the second connection with the server.
10. The method according to claim 9, characterized in that, The second time interval is: The product of the first time interval and a first constant, wherein the first constant is a positive number greater than 1; or, The sum of the first time interval and the second constant, where the second constant is a positive number; or, The average of the first time interval and the third constant, wherein the third constant is greater than the first time interval.
11. The method according to claim 9 or 10, characterized in that, Before determining the second period based on the second connection, the method further includes: After receiving the third response, the first type of heartbeat message is sent to the server through the first connection based on a third period, wherein the third period is the time interval between the first moment and the third moment.
12. The method according to claim 9 or 10, characterized in that, Before determining the second period based on the second connection, the method further includes: After receiving the third response, the first type of heartbeat message is sent to the server through the first connection based on a third period, wherein the third period is the difference between the time interval between the first time and the third time and a fourth constant.
13. The method according to claim 8, characterized in that, Prior to the third time point, the method further includes: At the fifth moment, a fifth message is sent to the server through the second connection, and the fifth message is a heartbeat message of the second type. A fifth response is received, wherein the fifth response is the server's response to the fifth message sent through the second connection; wherein the time interval between the fifth time and the third time is the third time interval, the time interval between the third time and the fourth time is the second time interval, and the third time interval is less than the second time interval.
14. The method according to claim 13, characterized in that, The second time interval is: The product of the third time interval and the first constant, where the first constant is a positive number greater than 1; or, The sum of the third time interval and the second constant, wherein the second constant is a positive number; or, The average of the third time interval and the third constant, wherein the third constant is greater than the third time interval.
15. The method according to claim 13 or 14, characterized in that, Before determining the second period based on the second connection, the method further includes: After receiving the third response, a heartbeat message of the first type is sent to the server through the first connection based on a fourth period; the fourth period is the time interval between the fifth time and the third time, or the fourth period is the difference between the time interval between the fifth time and the third time and a fourth constant.
16. The method according to claim 1 or 2, characterized in that, The moment when the first electronic device establishes the second connection with the server is the first moment; The determination of the second period based on the second connection specifically includes: At the sixth moment, a sixth message is sent to the server through the second connection. The sixth message is a heartbeat message of the second type. The sixth moment is later than the first moment. A sixth response is received, which is the server's response to the sixth message sent through the second connection; At the seventh moment, a seventh message is sent to the server through the second connection. The seventh message is a heartbeat message of the second type. The seventh moment is later than the sixth moment. The second connection was detected to be disconnected; When the stopping condition is detected, the second period is determined based on the time interval between the first time and the sixth time.
17. The method according to claim 1 or 2, characterized in that, The determination of the second period based on the second connection specifically includes: At the eighth moment, an eighth message is sent to the server through the second connection. The eighth message is a heartbeat message of the second type. The eighth response is received, which is the server's response to the eighth message sent through the second connection; At the ninth moment, a ninth message is sent to the server through the second connection. The ninth message is a heartbeat message of the second type. The ninth moment is later than the eighth moment. A ninth response is received, wherein the ninth response is the server's response to the ninth message sent through the second connection; At the tenth moment, a tenth message is sent to the server through the second connection. The tenth message is a heartbeat message of the second type. The tenth moment is later than the ninth moment. The second connection was detected to be disconnected; When the stopping condition is detected, the second period is determined based on the time interval between the eighth time and the ninth time.
18. The method according to claim 17, characterized in that, The second period is the time interval between the eighth time and the ninth time, or the difference between the time interval between the eighth time and the ninth time and the fourth constant.
19. The method according to claim 5, characterized in that, The stopping conditions include one or more of the following: The detection duration reaches the second duration, the number of times the second type of heartbeat message is sent through the second connection reaches the first count, and the number of times the second connection is established reaches the second count.
20. The method according to claim 1 or 2, characterized in that, After the first electronic device establishes a second connection with the server, the method further includes: At the eleventh moment, a heartbeat message of the first type is sent to the server through the first connection; At the twelfth moment, an eleventh message is sent to the server through the second connection. The eleventh message is a second type of heartbeat message. The twelfth moment is later than the eleventh moment, and the time interval between the eleventh moment and the twelfth moment is the fourth time interval. At the twelfth moment, a heartbeat message of the first type is sent to the server through the first connection, and the absolute value of the difference between the fourth time interval and the first period is less than the first threshold.
21. The method according to claim 1 or 2, characterized in that, The first electronic device establishes a first connection with the server, specifically including: The first electronic device establishes the first connection with the server through the second electronic device; The first electronic device establishes a second connection with the server, specifically including: The first electronic device establishes the second connection with the server through the second electronic device.
22. The method according to claim 1 or 2, characterized in that, The method further includes: The first electronic device establishes a third connection with the server; The determination of the second period based on the second connection specifically includes: The second period is determined based on the second connection and the third connection.
23. A communication system, characterized in that, The communication system includes a first electronic device, a first server, and a second server; The first electronic device is configured to establish a first connection with the first server and send a first type of heartbeat message to the first server based on a first period through the first connection. Establish a second connection with the second server, the second connection being used to transmit a second type of heartbeat message; determine a second period based on the second connection; send a first type of heartbeat message to the first server through the first connection based on the second period; disconnect the second connection; The first server is used to establish the first connection with the first electronic device, and the first connection is used to transmit business data and the first type of heartbeat message; The second server is used to establish the second connection with the first electronic device, and the second connection is used to transmit the second type of heartbeat message.
24. An electronic device, characterized in that, The device includes one or more memories and one or more processors; the one or more memories are coupled to the one or more processors, and the one or more memories are used to store computer program code, the computer program code including computer instructions, which, when executed by the one or more processors, cause the electronic device to perform the method of any one of claims 1-22.
25. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a computer program that, when run on an electronic device, causes the electronic device to perform the method as described in any one of claims 1-22.
26. A computer program product, characterized in that, The computer program product includes: a computer program or instructions that, when run on a computer, cause the computer to perform the method as described in any one of claims 1-22.
Citation Information
Patent Citations
Keep-alive method, device and system for data transmission link
CN103684815A
Equipment heartbeat interval control method and device, Internet of Things equipment and storage medium
CN114500550A