Session keep-alive method between client and server, client and medium
By alternately using TCP and UDP protocols to send heartbeat packets in video conferencing scenarios and re-establishing the connection within the timeout period, the problem of abnormal session interruption in the prior art is solved, and user experience and communication efficiency are improved.
Patent Information
- Application Number
- CN202410930119.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-11
- Publication Date
- 2024-11-01
AI Technical Summary
In business scenarios such as video conferencing, the network quality between the client and the server is difficult to predict, and the existing heartbeat mechanism is difficult to effectively maintain the session under high packet loss rate and bandwidth limitations, resulting in abnormal session interruption, affecting user experience and communication efficiency.
The preset heartbeat time and incremental heartbeat time are used to send heartbeat data packets alternately, and the TCP and UDP protocols are used to communicate separately to improve the reception probability of heartbeat data packets, and re-establish the connection within the timeout time to ensure the stability of the session.
It effectively reduces abnormal session interruptions between the client and the server, improves user experience and communication efficiency, and adapts to complex network quality conditions.
Smart Images

Figure CN118890380A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network technology for communication between a client and a server, and in particular to a method for keeping a session alive between a client and a server, and a corresponding client, a computer-readable medium and a computer device. Background Art
[0002] Applications involving network communication inevitably need to consider network stability and communication quality. Communication quality refers to the performance of data transmission stability, speed, delay, and packet loss rate during network communication. The quality of communication directly affects the user's network experience and service quality. Communication quality is affected by many factors, including but not limited to network congestion, bandwidth limitations, signal interference, jitter, packet loss, delay, etc. For example, in a business scenario such as video conferencing, after a video conferencing service session is established between the client and the server, the validity of the service session needs to be maintained to minimize the impact of factors such as short-term network interruptions and jitter on the stability of the service session.
[0003] For multi-party video conferencing business scenarios in remote locations, when the client and server communicate through a public network, the obsolescence and failure rate of network equipment in the public network are difficult to predict, as well as the randomness of addressing and positioning path selection. Therefore, the connection stability of the public network is low, and the communication quality is often not guaranteed. It is more likely to have network jitter and packet congestion in a short period of time, resulting in packet loss or delayed arrival. It is also difficult to unify the network access methods of the terminal running the client, such as wired, WiFi, 4G, 5G, etc. Various access methods lead to large differences in communication quality, and robustness is difficult to guarantee.
[0004] In order to maintain the validity of the session between the client and the server, a suitable heartbeat mechanism is usually configured for the communication between the client and the server. A typical heartbeat mechanism is to configure the client to periodically send a heartbeat data packet to the server indicating that the client is still online. After receiving the heartbeat data packet, the server knows that the client is still in the session, so as to avoid the server from misjudging that the client is offline, thereby disconnecting and releasing the session with the client. The heartbeat mechanism is an important means to keep the session between the client and the server alive.
[0005] However, in application scenarios where there are a large amount of real-time multimedia data and interactive instructions in the session, especially in business scenarios such as video conferencing, the current heartbeat mechanism is difficult to meet the requirements of effectively maintaining the session between the client and the server under various network conditions because the network quality between the client and the server is difficult to predict. For example, in a weak network with a high packet loss rate, the server may not be able to receive the heartbeat data packet in time due to packet loss, resulting in failure to keep the session alive. This phenomenon is more obvious when using a network communication protocol with a conservative retransmission strategy to implement the heartbeat mechanism. Even in a dedicated network with good connection performance, heartbeat data packets are often generated concurrently with a large number of media data packets. Due to the constraints of limited transmission resources such as bandwidth, heartbeat data packets may also be blocked. Once the session between the client and the server is forced to be interrupted, it will greatly affect the user experience and communication efficiency. Summary of the invention
[0006] In order to overcome the above defects in the prior art, the present invention provides a method for keeping a session alive between a client and a server, the method comprising:
[0007] After a session is established between the client and the server, the client is configured to continuously send heartbeat data packets to the server using the first network communication protocol or the second network communication protocol with a preset heartbeat duration as a period;
[0008] The timing starts with the time when the heartbeat data packet is sent as the starting timestamp, and the client determines whether the heartbeat response data of the server is received within the first timeout period;
[0009] If no heartbeat response data from the server is received within the first timeout period, the client is triggered to continuously send incremental heartbeat data packets to the server using a second network communication protocol with an incremental heartbeat period as a period, the incremental heartbeat period is less than the preset heartbeat period, the data transmission speed of the second network communication protocol is greater than the data transmission speed of the first network communication protocol, and / or the data packet complexity of the second network communication protocol is less than the data packet complexity of the first network communication protocol;
[0010] The timing starts with the time when the heartbeat data packet is sent as the starting timestamp, and the client determines whether the heartbeat response data of the server is received within a second timeout period, and the second timeout period is greater than the first timeout period;
[0011] If no heartbeat response data from the server is received within the second timeout period, the client is triggered to re-establish a connection with the server.
[0012] According to one aspect of the present invention, after sending the heartbeat data packet, the method further includes: the client receiving the service data packet sent by the server, and replacing the sending time with the receiving time of the service data packet to update the start timestamp.
[0013] According to another aspect of the present invention, the heartbeat data packet in the method includes synchronization information, and the synchronization information is used by the server to verify the status of the hardware device called by the client and / or to synchronize the business status of the client to the server.
[0014] According to another aspect of the present invention, after sending the incremental heartbeat data packet, the method also includes: starting timing with the time when the incremental heartbeat data packet is sent as the initial timestamp, the client determines whether the heartbeat response data of the server is received within a third timeout period, and the third timeout period is less than the first timeout period; if the result of the judgment is yes, triggering the client to stop sending the incremental heartbeat data packet to the server.
[0015] According to another aspect of the present invention, the preset heartbeat duration in the method is n seconds, the incremental heartbeat duration is n / 10 seconds, the first timeout duration is 5n seconds, the second timeout duration is 10n seconds, and the third timeout duration is 2n seconds.
[0016] According to another aspect of the present invention, in the method, the first network communication protocol is TCP, and the second network communication protocol is UDP.
[0017] According to another aspect of the present invention, the session in the method is a service session for transmitting real-time multimedia data and performing real-time instruction interaction; and the server is a signaling server.
[0018] According to another aspect of the present invention, the service session in the method is a video conference service session.
[0019] Accordingly, the present invention further provides a client, which includes:
[0020] A heartbeat module, configured to continuously send heartbeat data packets to the server using a first network communication protocol or a second network communication protocol with a preset heartbeat duration as a period after a session is established between the client and the server;
[0021] A first judgment module is used to start timing with the time when the heartbeat data packet is sent as a starting timestamp, and judge whether the heartbeat response data of the server is received within a first timeout period;
[0022] An incremental heartbeat module, used for continuously sending incremental heartbeat data packets to the server using a second network communication protocol with an incremental heartbeat duration as a period when the judgment result of the first judgment module is no, the incremental heartbeat duration is less than the preset heartbeat duration, the data transmission speed of the second network communication protocol is greater than the data transmission speed of the first network communication protocol, and / or the data packet complexity of the second network communication protocol is less than the data packet complexity of the first network communication protocol;
[0023] A second judgment module is used to start timing with the time when the heartbeat data packet is sent as a starting timestamp, and judge whether the heartbeat response data of the server is received within a second timeout period, and the second timeout period is greater than the first timeout period;
[0024] A reconnection module is used to re-establish a connection with the server when the judgment result of the second judgment module is no.
[0025] According to one aspect of the present invention, the client also includes: an update module, which is used to receive a business data packet sent by the server after the heartbeat module sends the heartbeat data packet, and use the reception time of the business data packet to replace the sending time to update the start timestamp.
[0026] According to another aspect of the present invention, the heartbeat data packet in the client includes synchronization information, and the synchronization information is used by the server to verify the status of the hardware device called by the client and / or to synchronize the service status of the client to the server.
[0027] According to another aspect of the present invention, the client also includes: a third judgment module, which is used to start timing with the time when the incremental heartbeat data packet is sent as the initial timestamp after the incremental heartbeat module sends the incremental heartbeat data packet, and judge whether the heartbeat response data of the server is received within a third timeout period, and the third timeout period is less than the first timeout period. If the result of the judgment is yes, the incremental heartbeat module is triggered to stop sending the incremental heartbeat data packet to the server.
[0028] According to another aspect of the present invention, the preset heartbeat duration in the client is n seconds, the incremental heartbeat duration is n / 10 seconds, the first timeout duration is 5n seconds, the second timeout duration is 10n seconds, and the third timeout duration is 2n seconds.
[0029] According to another aspect of the present invention, in the client, the first network communication protocol is TCP, and the second network communication protocol is UDP.
[0030] According to another aspect of the present invention, the session in the client is a service session for transmitting real-time multimedia data and performing real-time instruction interaction; and the server is a signaling server.
[0031] According to another aspect of the present invention, the service session in the client is a video conference service session.
[0032] In addition, the present invention provides one or more computer-readable media storing computer-executable instructions, which, when used by one or more computer devices, enable the one or more computer devices to execute the session keeping alive method between a client and a server based on homomorphic encryption as described above.
[0033] The present invention also provides a computer device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the session keeping method between the client and the server as described above when executing the computer program.
[0034] The session keep-alive method between the client and the server provided by the present invention introduces incremental heartbeat data packets with a higher sending frequency into the heartbeat mechanism, so that the heartbeat mechanism can better adapt to the complex network quality conditions between the client and the server, especially in business scenarios such as video conferencing, and effectively reduce abnormal session interruptions between the client and the server for short-term network terminations and jitters caused by different network access methods, thereby improving user experience and communication efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:
[0036] Figure 1 It is a flowchart of a specific implementation of the method for keeping a session alive between a client and a server according to the present invention;
[0037] Figure 2 is a flow chart of an optional specific implementation of a method for keeping a session alive between a client and a server according to the present invention;
[0038] Figure 3 is a structural diagram of a specific implementation of a client according to the present invention;
[0039] Figure 4 It is a structural schematic diagram of a typical computer device for implementing the functions of the client and the server in the method for keeping the session alive between the client and the server of the present invention;
[0040] Figure 5It is a structural schematic diagram of a typical intelligent terminal used to implement the client function in the session keep-alive method between the client and the server of the present invention.
[0041] The same or similar reference numerals in the drawings represent the same or similar components. DETAILED DESCRIPTION
[0042] In order to better understand and explain the present invention, the present invention will be further described in detail below in conjunction with the accompanying drawings. The present invention is not limited to these specific embodiments. On the contrary, modifications or equivalent substitutions made to the present invention should all be included in the scope of the claims of the present invention.
[0043] It should be noted that many specific details are given in the following specific embodiments. It should be understood by those skilled in the art that the present invention can also be implemented without these specific details. In the multiple specific embodiments given below, structures and components well known in the art are not described in detail in order to highlight the main purpose of the present invention.
[0044] The present invention provides a method for keeping a session alive between a client and a server. Figure 1 , Figure 1 FIG. 1 is a flow chart of a specific implementation of a method for keeping a session alive between a client and a server according to the present invention. Figure 1 As shown, the method includes:
[0045] Step S100, after a session is established between the client and the server, the client is configured to continuously send heartbeat data packets to the server using the first network communication protocol or the second network communication protocol with a preset heartbeat duration as a period;
[0046] Step S200, starting timing with the time when the heartbeat data packet is sent as the starting timestamp, the client determines whether the heartbeat response data of the server is received within the first timeout period, and further, if the result of the determination in step S200 is no, executing step S300;
[0047] Step S300, triggering the client to continuously send incremental heartbeat data packets to the server using a second network communication protocol with an incremental heartbeat duration as a period, wherein the incremental heartbeat duration is less than the preset heartbeat duration;
[0048] Step S400, starting timing with the time when the heartbeat data packet is sent as the starting timestamp, the client determines whether the heartbeat response data of the server is received within a second timeout period, and the second timeout period is greater than the first timeout period. Further, if the result of the judgment in step S400 is no, executing step S500;
[0049] Step S500, triggering the client to re-establish a connection with the server.
[0050] Specifically, the term "keep alive" refers to maintaining the connection between the client and the server from being disconnected, that is, maintaining the effective connection of the session between the client and the server. For example, when the client and the server communicate using the Transmission Control Protocol (TCP), the direct effect of keep alive is to maintain a long connection between the client and the server.
[0051] Typically, the session between the client and the server is a business session used to transmit real-time multimedia data and perform real-time command interaction, such as a video conferencing business session. Keeping the session alive can obviously avoid abnormal session interruptions caused by poor network quality, thereby improving user experience and communication efficiency.
[0052] In a video conferencing solution built using Web Real-Time Communications (WebRTC), the client is a browser. In order to enable multiple clients participating in the video conference to establish a point-to-point video data transmission connection with each other, and to globally control the session, configuration information, and information exchange in the entire video conference, the server is usually a signaling server. Optionally, the server may also be a multi-functional server that integrates the functional logic for implementing the signaling server.
[0053] In traditional video conferencing solutions or those based on WebRTC technology, those skilled in the art are aware that, as the video conference proceeds, the real-time multimedia data and real-time instructions generated are continuously concurrent, and the heartbeat data packet used to keep the session alive in step S100 may still not be transmitted to the server side in time due to various reasons such as data packet blocking and poor network quality. Figure 1 In the specific implementation of the session keep-alive method between the client and the server of the present invention, steps S100 to S500 are performed to ensure that the session keep-alive is successful as much as possible.
[0054] In step S100, after a session is established between the client and the server, a heartbeat mechanism is constructed in such a way that the client actively and periodically generates heartbeat data packets, that is, the client is configured to continuously send heartbeat data packets to the server using the first network communication protocol or the second network communication protocol with a preset heartbeat duration as a period.
[0055] In step S200, the client makes a first judgment on whether the server responds to the heartbeat data packet, that is, the timing starts with the time when the heartbeat data packet is sent as the starting timestamp, and the client judges whether the heartbeat response data of the server is received within the first timeout period (the heartbeat response data can also be called heartbeat response data in the industry). There may be multiple reasons for the result of the judgment in step S200 to be no. One reason is that the heartbeat data packet fails to reach the server, and the server does not know whether the client is still online, so it will not actively send the heartbeat response data to the client out of thin air; another reason is that the heartbeat response data fails to reach the client in time, and the client cannot judge whether the heartbeat data packet is successfully responded by the server. Regardless of which reason, in this specific implementation, when the result of the judgment in step S200 is no, further consideration is given to enhancing the connection robustness of the heartbeat mechanism between the client and the server to offset the heartbeat data packet loss caused by poor network quality, that is, executing step S300.
[0056] As mentioned above, the fundamental purpose of executing step S300 is to allow the server to have a higher probability of receiving the information sent by the client for the heartbeat mechanism, such as increasing the information density of the heartbeat data between the client and the server, thereby improving the connection robustness of the heartbeat mechanism between the client and the server. Therefore, the specific means of step S300 is: triggering the client to continuously send incremental heartbeat data packets to the server using the second network communication protocol with the incremental heartbeat duration as a period, and the incremental heartbeat duration is less than the preset heartbeat duration. Obviously, the sending frequency of the incremental heartbeat data packet is higher than that of the heartbeat data packet, which further increases the information density of the heartbeat data between the client and the server. Preferably, the incremental heartbeat data packet can be designed to have a smaller data volume than the heartbeat data packet, and is designed not to include any additional information, and only contains information sufficient to trigger the server to generate the heartbeat response data.
[0057] Whether it is the heartbeat data packet or the incremental heartbeat data packet, it can trigger the server to feed back the heartbeat response data to the client. The incremental heartbeat data packet can be regarded as a redundant supplement to the heartbeat data packet based on the consideration of enhancing the robustness of the heartbeat mechanism. Compared with the heartbeat data packet, sending the incremental heartbeat data packet to the client at a higher frequency can undoubtedly increase the probability that the server receives the heartbeat data of the client. From another perspective, in order to further increase the above probability, it should be designed so that the data transmission speed of the second network communication protocol is greater than the data transmission speed of the first network communication protocol, and / or the data packet complexity of the second network communication protocol is less than the data packet complexity of the first network communication protocol. Taking advantage of the characteristics of faster data transmission or lower data packet complexity of the second network communication protocol, in step S300, only the second network communication protocol is used to send the incremental heartbeat data packet to increase the probability.
[0058] Typically, the first network communication protocol is TCP, and the second network communication protocol is User Datagram Protocol (UDP).
[0059] As is known to those skilled in the art, TCP is a connection-oriented protocol. Before data transmission, both parties need to establish a clear connection. This connection ensures the order and integrity of the data. Data transmission based on TCP is generally considered to be reliable data transmission. TCP uses sequence numbers to number data and allows the receiving end to confirm the receipt of data packets. If a data packet is lost during transmission, TCP will retransmit the data to ensure the integrity of the data. The TCP mechanism ensures the reliable transmission of data, but it may also lead to higher latency and lower throughput. At the same time, TCP has built-in flow control and congestion control mechanisms. The purpose of these mechanisms is to ensure that the network does not collapse due to overload. When the network is congested, TCP will slow down the sending rate or temporarily stop sending data to prevent the network congestion from further aggravating. Due to the complexity of TCP and the limitation of data integrity, TCP will have a higher delay because TCP needs to perform multiple handshakes, confirmations and retransmissions, which will increase the time of data transmission. However, for sending incremental heartbeat packets, the various characteristics of TCP are not helpful in increasing the probability of the incremental heartbeat packets being received by the server, and even have the opposite effect. For example, in a video conferencing scenario, the client will also simultaneously access a media server that uses UDP to transmit video and audio data. If the access bandwidth is limited, using TCP to transmit the incremental heartbeat data packet may cause its transmission to be suspended or fail.
[0060] It is also known to those skilled in the art that UDP is a connectionless protocol that does not require a connection to be established in advance, but directly sends data. The data packets sent in UDP are independent and may arrive at the destination in any order. UDP does not guarantee reliable transmission of data, but only focuses on fast transmission of data. For transmitting the incremental heartbeat data packet, the simplicity and low latency of UDP help increase the probability that the incremental heartbeat data packet is received by the server.
[0061] In addition, the header of a TCP data packet is 20 bytes, which contains a lot of control information, such as sequence number, acknowledgment number and window size, which are used to ensure reliable transmission and sequential arrival of data. The header of a UDP data packet is relatively small, only 8 bytes, and only contains the necessary source and destination information. This smaller header overhead also makes UDP have faster data transmission speed and smaller data packet complexity than TCP.
[0062] The network communication protocol used by the client to send the heartbeat data packet in step S100 is optional, and the selection may be determined based on factors such as the security requirements of the server. For example, in scenarios involving financial services such as banks and insurance, the server has high security requirements and may require only one type of network communication protocol to be opened for signaling interaction, such as only one of TCP and UDP.
[0063] When the first network communication protocol is selected to send the heartbeat data packet in step S100, the second network communication protocol is selected to send the incremental heartbeat data packet in step S300, which is improved in multiple dimensions such as transmission speed and information density to increase the probability that the server receives the heartbeat data of the client. When the second network communication protocol is selected to send the heartbeat data packet in step S100, the same second network communication protocol is selected to send the incremental heartbeat data packet in step S300, which is improved at least in the dimension of information density, and can also increase the probability that the server receives the heartbeat data of the client.
[0064] Although step S300 is executed, under the most unfavorable network conditions, the server may not be able to normally receive the heartbeat data packet or the incremental heartbeat data packet sent by the client, or the heartbeat response data of the server in response to the heartbeat data packet or the incremental heartbeat data packet may not be received by the client in time. At this time, due to the response timeout of the heartbeat mechanism, the session between the client and the server is forced to be interrupted, and it is necessary to consider reconnecting the client and the server. Consider executing step S400, that is, starting the timing with the time when the heartbeat data packet is sent as the starting timestamp, and the client determines whether the heartbeat response data of the server is received within the second timeout period, and the second timeout period is greater than the first timeout period. Further, if the result of the judgment in step S400 is no, execute step S500. Step S500 triggers the client to reconnect with the server.
[0065] Preferably, it is found through experiments that if the preset heartbeat duration is set to n seconds (n is a positive integer), the incremental heartbeat duration is set to n / 10 seconds, the first timeout duration is set to 5n seconds, and the second timeout duration is set to 10n seconds, the client and the server can form a complete heartbeat mechanism interaction as soon as possible while taking into account various factors such as various network qualities and the load of the server.
[0066] Those skilled in the art can understand that the reception of the heartbeat response data fed back by the server by the client indicates that the session between the client and the server is still in a valid connection state, and the session has not been interrupted, disconnected or released by the server. It is not difficult to find that any data packet received by the client from the server has a similar effect as the heartbeat response data. Preferably, Figure 1In the specific implementation shown, after sending the heartbeat data packet in step S100, the method may further include the following additional steps: the client receives the service data packet sent by the server, and replaces the sending time with the receiving time of the service data packet to update the starting timestamp. The service data packet may be actively sent by the server to the client, or may be triggered and sent to the client in response to the instructions of the client or other clients, such as a shared camera request data packet sent by other clients to the client. In the heartbeat mechanism, the service data packet is regarded as having the same properties as the heartbeat response data, which is sufficient to indicate that the session between the client and the server is still in a valid connection state. The advantage of performing this additional step is that when the starting timestamp is updated, the response status of the server relative to the client is updated accordingly, avoiding step S300 or step S500 from being triggered and executed in unnecessary situations, which not only reduces the amount of data communicated between the client and the server, but also reduces the load of the server.
[0067] Similarly, when the session between the client and the server is in an effective active state, in order to prevent the business states of the client and the server from being inconsistent, the client also needs to periodically synchronize the business state with the server, and the data carrier for synchronizing the business state can be implemented using the heartbeat data packet. Preferably, the heartbeat data packet includes synchronization information, and the synchronization information is used by the server to verify the state of the hardware device called by the client, and / or is used to synchronize the business state of the client to the server. For example, the synchronization information is information describing the state of the hardware devices such as the camera and microphone called by the client, and / or the synchronization information is information describing the permissions of the account corresponding to the client. It can be understood by those skilled in the art that any periodically generated data packet sent by the client to the server can serve as the heartbeat data packet. The advantage of attaching the synchronization information to the heartbeat data packet by utilizing the periodic transmission characteristics of the heartbeat data packet is that the client does not need to generate additional periodic synchronization data packets to complete the state synchronization function with the server, thereby reducing the communication load between the client and the server and improving the communication efficiency between the client and the server.
[0068] After the client is triggered to periodically send the incremental heartbeat data packet in step S300, the amount of data sent by the client to the server increases immediately. It has been introduced in the foregoing that the sending frequency of the incremental heartbeat data packet is preferably 10 times that of the heartbeat data packet. For the server, if multiple clients are triggered to generate the incremental heartbeat data packet at the same time, it will be a challenge to the network receiving and processing capabilities of the server. Therefore, it is also necessary to configure a stop strategy for the incremental heartbeat data packet on the client side to prevent the occurrence of extreme situations such as the server being overwhelmed and stopping responding.
[0069] Based on this consideration, please refer to Figure 2 , Figure 2 is a flow chart of an optional specific implementation method of a session keeping alive method between a client and a server according to the present invention, and Figure 1 The embodiment shown differs in that Figure 2 In the specific implementation shown, after sending the incremental heartbeat data packet in step S300, the session keep-alive method between the client and the server further includes the following steps:
[0070] Step S600, starting timing with the time when the incremental heartbeat data packet is sent as the initial timestamp, the client determines whether the heartbeat response data of the server is received within a third timeout period, and the third timeout period is less than the first timeout period. If the result of the determination is yes, executing step S700;
[0071] Step S700, triggering the client to stop sending the incremental heartbeat data packet to the server.
[0072] Preferably, it is found through experiments that the preset heartbeat duration is also set to n seconds, and the third timeout duration is set to 2n seconds, which can facilitate the client and the server to form a complete heartbeat mechanism interaction as soon as possible. Once the client receives the heartbeat response data of the server within 2n seconds, the client immediately stops sending the incremental heartbeat data packet to the server. This incremental heartbeat data packet stop strategy will not significantly increase the load of the server, and can also quickly help the client eliminate the abnormal connection of the server. For the application scenario in which the server simultaneously counts multiple clients, it is rare for multiple clients to trigger the incremental heartbeat data packet due to network quality at the same time. Usually, only a small number of clients will briefly trigger the incremental heartbeat data packet, thereby avoiding the occurrence of extreme situations such as the server being overwhelmed and stopping responding.
[0073] Figure 1 and Figure 2In the specific implementation shown, the client is preferably implemented as a software product, which runs on a personal computer or smart terminal with a suitable hardware environment. Typically, the software product is an application, a browser, or a small program application integrated in the application. In more embodiments, the client can also be implemented using software combined with hardware, for example, implemented as an integrated packaged device product.
[0074] It should be noted that, although the operations of multiple specific embodiments of the method of the present invention are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. On the contrary, the steps depicted in the flow chart can be changed in the order of execution. Additionally or alternatively, some steps can be omitted, multiple steps can be combined into one step for execution, and / or one step can be decomposed into multiple steps for execution.
[0075] Accordingly, the present invention also provides a client, please refer to Figure 3 , Figure 3 is a structural diagram of a specific implementation of a client according to the present invention, such as Figure 3 As shown, the client 100 includes:
[0076] The heartbeat module 110 is used to continuously send heartbeat data packets to the server 200 using the first network communication protocol or the second network communication protocol with a preset heartbeat duration as a period after a session is established between the client 100 and the server 200;
[0077] The first judgment module 120 is used to start timing with the time when the heartbeat data packet is sent as the starting timestamp, and judge whether the heartbeat response data of the server 200 is received within a first timeout period;
[0078] The incremental heartbeat module 130 is used to, when the judgment result of the first judgment module 120 is no, use the second network communication protocol to continuously send incremental heartbeat data packets to the server 200 with the incremental heartbeat duration as a period, the incremental heartbeat duration is less than the preset heartbeat duration, the data transmission speed of the second network communication protocol is greater than the data transmission speed of the first network communication protocol, and / or the data packet complexity of the second network communication protocol is less than the data packet complexity of the first network communication protocol;
[0079] A second judgment module 140 is used to start timing with the time when the heartbeat data packet is sent as a starting timestamp, and to judge whether the heartbeat response data of the server 200 is received within a second timeout period, and the second timeout period is greater than the first timeout period;
[0080] The reconnection module 150 is used to re-establish a connection with the server 200 when the judgment result of the second judgment module is no.
[0081] The terms and nouns appearing in this section have the same meaning as the same terms or nouns in the previous text, such as the "heartbeat data packet", "incremental heartbeat data packet", "heartbeat response data", etc. The above terms or nouns and the working principles involved can refer to the description and explanation of the relevant parts in the previous text. For the sake of simplicity, they will not be repeated here.
[0082] Specifically, the session is a service session for transmitting real-time multimedia data and performing real-time command interaction; the server 200 is a signaling server. Typically, the client 100 is used in an application scenario of a video conference, and the service session is a video conference service session. Figure 3 The media server 300 shown is used to send real-time multimedia data to the client 100 in real time.
[0083] Optionally, the first network communication protocol is TCP, and the second network communication protocol is UDP.
[0084] Preferably, if Figure 3 As shown, the client 100 also includes an update module 160, which is used to receive a business data packet sent by the server 200 after the heartbeat module 110 sends the heartbeat data packet, and use the reception time of the business data packet to replace the sending time to update the start timestamp.
[0085] Preferably, the heartbeat data packet includes synchronization information, and the synchronization information is used by the server 200 to verify the status of the hardware device called by the client 100 and / or to synchronize the service status of the client 100 with the server 200.
[0086] Preferably, the client 100 also includes a third judgment module 170, which is used to start timing with the time when the incremental heartbeat data packet is sent as the initial timestamp after the incremental heartbeat module 130 sends the incremental heartbeat data packet, and judge whether the heartbeat response data of the server 200 is received within a third timeout period, and the third timeout period is less than the first timeout period. If the result of the judgment is yes, the incremental heartbeat module 130 is triggered to stop sending the incremental heartbeat data packet to the server 200.
[0087] Optionally, the preset heartbeat duration is n seconds, the incremental heartbeat duration is n / 10 seconds, the first timeout duration is 5n seconds, the second timeout duration is 10n seconds, and the third timeout duration is 2n seconds.
[0088] In some embodiments, the server 100 may be composed of one server device; in other embodiments, the server 100 may also be composed of multiple server devices distributed and running on the Internet, and each functional module separated from the software program runs on the multiple servers. The software program may be implemented as a hardware part and a software part that can be interpreted and executed by the hardware part, and the hardware part and the software part work together to realize the functions of the server.
[0089] Please refer to Figure 4 , Figure 4 It is a schematic diagram of the structure of a typical computer device for implementing the functions of the client and the server in the method for keeping the session alive between the client and the server of the present invention. More specifically, the automation device for executing the method for keeping the session alive between the client and the server described above can be included as a part of the computer device. The computer device at least includes the following parts: CPU (central processing unit) 401, RAM (random access memory) 402, ROM (read-only memory) 403, system bus 400, hard disk control unit 404, hard disk 405, human-computer interaction external device control unit 406, human-computer interaction external device 407, serial interface control unit 408, serial interface external device 409, parallel interface control unit 410, parallel interface external device 411, display device control unit 412 and display device 413. Among them, CPU 401, RAM 402, ROM 403, hard disk control unit 404, human-computer interaction external device control unit 406, serial interface control unit 408, parallel interface control unit 410 and display device control unit 412 are connected to the system bus 400, and realize communication between each other through the system bus 400. In addition, the hard disk control unit 404 is connected to the hard disk 405; the human-computer interaction external device control unit 406 is connected to the human-computer interaction external device 407, which is typically a mouse, a trackball, a touch screen or a keyboard; the serial interface control unit 408 is connected to the serial interface external device 409; the parallel interface control unit 410 is connected to the parallel interface external device 411; and the display device control unit 412 is connected to the display device 413.
[0090] Figure 4 The structural block diagram merely shows the structure of a computer device that can practice various embodiments of the present invention, and is not intended to limit the practice environment of the present invention. In some cases, some devices in the computer device can be added or reduced as needed. For example, Figure 4 The device shown can remove the human-computer interaction external device 407 and the display device 413, and its specific implementation form is only a server that can be accessed by external devices. Figure 4The computer devices shown can independently provide an operating environment for each specific embodiment of the present invention, or can be interconnected through a network to provide an operating environment suitable for each specific embodiment of the present invention. For example, the various modules and / or steps of the present invention can be implemented in a distributed manner in various interconnected computer devices.
[0091] Please refer to Figure 5 , Figure 5 is a schematic diagram of a typical intelligent terminal structure for implementing the client function in the method for keeping a session alive between a client and a server of the present invention, Figure 5 The common structure of the intelligent terminal is schematically shown. Figure 5 Describes the internal components, software, and protocol structure of common smart terminals.
[0092] The smart terminal has a processor 510, which is responsible for the overall operation of the mobile terminal and can be implemented using any commercially available central processing unit (CPU), digital signal processor (DSP) or any other electronic programmable logic device (PLD). The processor 510 has an associated memory 520, which includes but is not limited to RAM memory, ROM memory, EEPROM memory, flash memory or a combination thereof. The memory 520 is controlled by the processor 510 for various purposes, one of which is to store program instructions and data for various software in the smart terminal.
[0093] The software layer of the intelligent terminal includes a real-time operating system 540, a driver for a human-machine interface 560, an application processor 550, and various applications. The applications are, for example, a text editor 551, a handwriting recognition application 552, and other multimedia applications 553, typically including applications such as voice call applications, video call applications, applications for sending and receiving short message service (SMS) messages, multimedia message service (MMS) applications or email applications, web browsers, instant messaging applications, phone book applications, calendar applications, control panel applications, camera applications, one or more video games, notepad applications, etc. It should be noted that two or more of the above applications can be executed as the same application.
[0094] The smart terminal also includes one or more hardware controllers, which are used to cooperate with the driver of the human-machine interface 560, the display device 561, the physical button 562, the microphone 563 and various I / O devices (such as speakers, vibrators, ring generators, LED indicators, etc.) to achieve human-machine interaction of the smart terminal. Those skilled in the art should understand that the user can operate the mobile terminal through the human-machine interface 560 formed in this way.
[0095] The software layer of the intelligent terminal can also include various modules, protocol stacks, drivers and other communication-related logic, which can be summarized as follows: Figure 4 The communication interface 570 shown in the figure is used to provide communication services (such as transmission, network and connectivity) for the wireless radio frequency interface 571 and optionally for the Bluetooth interface 572 and / or the infrared interface 573 to realize the interconnection and intercommunication of the intelligent terminal. The wireless radio frequency interface 571 includes an internal or external antenna and an appropriate circuit for establishing and maintaining a wireless link to the base station. As is well known to those skilled in the art, the circuit includes a series of analog and digital electronic components, which together form a radio receiver and transmitter. These components include, for example, bandpass filters, amplifiers, mixers, local oscillators, low-pass filters, AD / DA converters, etc.
[0096] The smart terminal may further include a card reader 530 , which is used to read information from a SIM card and use the information as a basis to cooperate with the wireless radio frequency interface 571 to access a network provided by an operator.
[0097] In addition, the present invention also discloses one or more computer-readable media storing computer-executable instructions, which, when used by one or more computer devices, enable one or more computer devices to execute various specific embodiments of the method for keeping a session alive between a client and a server as described above, such as Figure 1 The specific implementation shown. The computer-readable medium can be any available medium that can be accessed by a computer device, and includes volatile and non-volatile media, removable and non-removable media implemented by any method and technology to store information such as computer-readable instructions, data structures, program modules or other data. Computer-readable media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disk (DVD) or other optical storage, cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computing device. Any combination of the above should also be included in the scope of computer-readable media.
[0098] Accordingly, the present invention further discloses a computer device, the computer device comprising a memory and a processor, wherein: the memory stores a computer program, and the processor implements various specific implementations of the session keeping alive method between the client and the server as described above when executing the computer program, for example Figure 1 The specific implementation shown.
[0099] The part involving software logic in the session keeping method between the client and the server provided by the present invention can be implemented using a programmable logic device, or can be implemented as a computer program product, which enables a computer to execute the method demonstrated. The computer program product includes a computer-readable storage medium, which contains a computer program logic or code part, and is used to implement the various steps of the above-mentioned part involving software logic. The computer-readable storage medium can be a built-in medium installed in the computer or a removable medium (such as a hot-swappable storage device) that can be removed from the computer body. The built-in medium includes but is not limited to a rewritable non-volatile memory, such as RAM, ROM and hard disk. The removable medium includes but is not limited to: optical storage media (such as CD-ROM and DVD), magneto-optical storage media (such as MO), magnetic storage media (such as magnetic tape or mobile hard disk), a medium with a built-in rewritable non-volatile memory (such as a memory card) and a medium with a built-in ROM (such as a ROM box).
[0100] Those skilled in the art will appreciate that any computer system with an appropriate programming device can perform the steps of the method of the present invention contained in the computer program product. Although most of the specific embodiments described in this specification focus on software programs, alternative embodiments that implement the method provided by the present invention in hardware are also within the scope of the present invention.
[0101] It is obvious to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential features of the present invention. Therefore, the embodiments should be regarded as exemplary and non-restrictive, and the scope of the present invention is defined by the appended claims rather than the above description, and all changes within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any figure mark in the claims should not be regarded as limiting the claims involved. In addition, it is obvious that the word "comprising" does not exclude other parts, units or steps, and the singular does not exclude the plural. Multiple parts, units or devices stated in the claims may also be implemented by one part, unit or device through software or hardware.
[0102] The session keep-alive method between the client and the server provided by the present invention introduces incremental heartbeat data packets with a higher sending frequency into the heartbeat mechanism, so that the heartbeat mechanism can better adapt to the complex network quality conditions between the client and the server, especially in business scenarios such as video conferencing, and effectively reduce abnormal session interruptions between the client and the server for short-term network terminations and jitters caused by different network access methods, thereby improving user experience and communication efficiency.
[0103] The above disclosures are only some preferred embodiments of the present invention, which cannot be used to limit the scope of rights of the present invention. Equivalent changes made according to the claims of the present invention are still within the scope of the present invention.
Claims
1. A method for keeping a session alive between a client and a server, the method comprising: After a session is established between the client and the server, the client is configured to continuously send heartbeat data packets to the server using the first network communication protocol or the second network communication protocol with a preset heartbeat duration as a period; The timing starts with the time when the heartbeat data packet is sent as the starting timestamp, and the client determines whether the heartbeat response data of the server is received within the first timeout period; If no heartbeat response data from the server is received within the first timeout period, the client is triggered to continuously send incremental heartbeat data packets to the server using a second network communication protocol with an incremental heartbeat period as a period, the incremental heartbeat period is less than the preset heartbeat period, the data transmission speed of the second network communication protocol is greater than the data transmission speed of the first network communication protocol, and / or the data packet complexity of the second network communication protocol is less than the data packet complexity of the first network communication protocol; The timing starts with the time when the heartbeat data packet is sent as the starting timestamp, and the client determines whether the heartbeat response data of the server is received within a second timeout period, and the second timeout period is greater than the first timeout period; If no heartbeat response data from the server is received within the second timeout period, the client is triggered to re-establish a connection with the server.
2. The session keep-alive method according to claim 1, after sending the heartbeat data packet, the method further comprises: The client receives the service data packet sent by the server, and uses the reception time of the service data packet to replace the sending time, so as to update the start timestamp.
3. The session keeping alive method according to claim 1, wherein: The heartbeat data packet includes synchronization information, and the synchronization information is used by the server to verify the status of the hardware device called by the client and / or to synchronize the service status of the client to the server.
4. The session keep-alive method according to claim 1, after sending the incremental heartbeat data packet, the method further comprises: The client determines whether the heartbeat response data of the server is received within a third timeout period, and the third timeout period is less than the first timeout period. If the result of the judgment is yes, the client is triggered to stop sending the incremental heartbeat data packet to the server.
5. The session keeping alive method according to claim 4, wherein: The preset heartbeat duration is n seconds, the incremental heartbeat duration is n / 10 seconds, the first timeout duration is 5n seconds, the second timeout duration is 10n seconds, and the third timeout duration is 2n seconds.
6. The session keeping alive method according to claim 1, wherein: The first network communication protocol is TCP, and the second network communication protocol is UDP.
7. The session keeping alive method according to claim 1, wherein: The session is a service session for transmitting real-time multimedia data and performing real-time instruction interaction; The server is a signaling server.
8. The session keeping alive method according to claim 7, wherein: The service session is a video conference service session.
9. A client, comprising: A heartbeat module, configured to continuously send heartbeat data packets to the server using a first network communication protocol or a second network communication protocol with a preset heartbeat duration as a period after a session is established between the client and the server; A first judgment module is used to start timing with the time when the heartbeat data packet is sent as a starting timestamp, and judge whether the heartbeat response data of the server is received within a first timeout period; An incremental heartbeat module, used for continuously sending incremental heartbeat data packets to the server using a second network communication protocol with an incremental heartbeat duration as a period when the judgment result of the first judgment module is no, the incremental heartbeat duration is less than the preset heartbeat duration, the data transmission speed of the second network communication protocol is greater than the data transmission speed of the first network communication protocol, and / or the data packet complexity of the second network communication protocol is less than the data packet complexity of the first network communication protocol; A second judgment module is used to start timing with the time when the heartbeat data packet is sent as a starting timestamp, and judge whether the heartbeat response data of the server is received within a second timeout period, and the second timeout period is greater than the first timeout period; A reconnection module is used to re-establish a connection with the server when the judgment result of the second judgment module is no.
10. The client according to claim 9, further comprising: An updating module is used to receive a service data packet sent by the server after the heartbeat module sends the heartbeat data packet, and use the receiving time of the service data packet to replace the sending time to update the starting timestamp.
11. The client according to claim 9, wherein: The heartbeat data packet includes synchronization information, and the synchronization information is used by the server to verify the status of the hardware device called by the client and / or to synchronize the service status of the client to the server.
12. The client according to claim 9, further comprising: A third judgment module is used to start timing with the time when the incremental heartbeat data packet is sent as the initial timestamp after the incremental heartbeat module sends the incremental heartbeat data packet, and judge whether the heartbeat response data of the server is received within a third timeout period, and the third timeout period is less than the first timeout period. If the result of the judgment is yes, the incremental heartbeat module is triggered to stop sending the incremental heartbeat data packet to the server.
13. The client according to claim 12, wherein: The preset heartbeat duration is n seconds, the incremental heartbeat duration is n / 10 seconds, the first timeout duration is 5n seconds, the second timeout duration is 10n seconds, and the third timeout duration is 2n seconds.
14. The client according to claim 9, wherein: The first network communication protocol is TCP, and the second network communication protocol is UDP.
15. The client according to claim 9, wherein: The session is a service session for transmitting real-time multimedia data and performing real-time instruction interaction; The server is a signaling server.
16. The client according to claim 15, wherein: The service session is a video conference service session.
17. One or more computer-readable media storing computer-executable instructions, which, when used by one or more computer devices, cause the one or more computer devices to execute the session keeping alive method between a client and a server according to any one of claims 1 to 8.
18. A computer device comprising a memory and a processor, wherein: The memory stores a computer program, and when the processor executes the computer program, the session keeping method between the client and the server according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Heartbeat detection method of wireless sensor network and apparatus thereof
CN104918267A
A server link state monitoring method, device and system, an electronic apparatus and a storage medium
CN108092853A
Heartbeat data packet sending method
CN109547293A
Heartbeat processing method and device of application program, electronic equipment and storage medium
CN110474975A
Transmission protocol switching method, device and equipment and storage medium
CN111224999A
