WebRTC-based connection keep-alive method, device, apparatus and medium
By collecting network and user behavior data in real time and combining reinforcement learning to optimize the WebRTC keep-alive strategy, the problem of insufficient connection stability and user experience in existing technologies is solved. Adaptive, low-power connection keep-alive is achieved, improving the connection success rate and user interaction efficiency in complex network environments.
Patent Information
- Application Number
- CN202511196171.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-26
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2045-08-26
AI Technical Summary
Existing WebRTC connection keep-alive solutions suffer from resource waste, high connection failure rates, and poor user experience when faced with network fluctuations and differences in user behavior. They are unable to dynamically adjust strategies to adapt to different network environments and user operating habits.
By collecting network quality and user behavior data in real time and combining reinforcement learning, the WebRTC keep-alive strategy is dynamically optimized, including adjusting the heartbeat interval, retransmission mechanism and interface layout. A multi-channel redundancy strategy is adopted to adapt to different user types, achieving adaptive and low-power connection keep-alive.
It improves connection success rate and user experience, reduces resource consumption, enhances connection stability and interaction efficiency in complex network environments, adapts to different user behaviors, and reduces misjudgment and disconnection rates.
Smart Images

Figure CN120711060B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of communication technology, in particular, to a WebRTC-based connection keep-alive method, device, equipment and medium. BACKGROUND
[0002] At present, the application of WebRTC technology in the field of real-time communication has been deep into video conferencing, remote medical treatment, online education, industrial Internet of Things (such as remote device control) and other scenarios. However, the existing connection keep-alive scheme has the following core defects:
[0003] Single heartbeat mechanism: only sending heartbeat packets at fixed intervals to maintain the connection, without combining user behavior characteristics and network dynamic changes, resulting in resource waste or keep-alive failure.
[0004] Insufficient environmental adaptability: unable to distinguish between weak network (such as mobile network) and strong network (such as fiber network) scenarios, unable to dynamically adjust the keep-alive strategy, with a connection disconnection rate of up to 15%-20% in complex network environments.
[0005] Fragmented user experience: fixed interface layout, no association with user behavior data, resulting in low interaction efficiency, such as more than 30% of important function modules being ignored by users due to unreasonable layout. SUMMARY
[0006] The present application provides a WebRTC-based connection keep-alive method, which solves the technical problems that the existing keep-alive technology cannot cope with network fluctuations, power consumption and traffic consumption, cannot adapt to user's personalized operation habits, and cannot dynamically adjust the keep-alive strategy.
[0007] The present application is implemented by the following scheme:
[0008] A WebRTC-based connection keep-alive method, comprising the steps of:
[0009] S1, collecting network quality data, user operation behavior data, browser performance indicators and network system parameters in real time, constructing a state vector, and the system parameters include heartbeat interval and retransmission times;
[0010] S2, fusing user operation behavior data, network quality data and interface interaction data, generating interface optimization suggestions, WebRTC keep-alive strategies for different types of users through reinforcement learning and continuously optimizing;
[0011] S3, executing the generated interface optimization suggestions and WebRTC keep-alive strategies, sending operation instructions to WebRTC, sending keep-alive data packets through the data channel DataChannel of WebRTC, and using the WebSocket channel as a backup to realize channel redundancy when the network fluctuates;
[0012] S4, receiving the operation instruction through the connection object RTCPeerConnection of WebRTC, being responsible for audio / video and data transmission and feeding back the adjusted connection state change and network quality data.
[0013] Further, in the step S1, the real-time collection of the user operation behavior data specifically includes the steps of:
[0014] S11, multi-modal data collection: including user operation behavior data and browser performance indicators, the user operation behavior data including basic operation behavior, immersive interaction data and browser performance data, the basic operation behavior including clicking, sliding track, keyboard input frequency; the immersive interaction data including eye tracking, voice instruction keyword recognition; the browser performance data including browser memory occupation, GPU rendering frame rate monitoring;
[0015] S12, space-time feature modeling: introducing a time series analysis model to construct a user behavior trajectory matrix X for the user operation behavior data:
[0016] ;
[0017] In the formula, n is the feature dimension;
[0018] S13, weighting the influence factor of different user operation behaviors on connection activity through an attention mechanism.
[0019] Further, the step S2 specifically includes the steps of:
[0020] S21, according to the collected user operation behavior data and the improved DBSCAN algorithm, dividing the users into active type, intermittent type and silent type according to the operation type;
[0021] S22, constructing a network health index by real-time collection of network quality data:
[0022] ;
[0023] wherein, RTT is the round-trip delay, P is the packet loss rate, Δ B is the bandwidth fluctuation coefficient, ω 1, ω 2, ω 3 is the corresponding dynamic weight coefficient;
[0024] S23, combine user operation behavior data, network health index and interface interaction data, use reinforcement learning Q-Learning to dynamically optimize and adjust WebRTC keep-alive parameters and interface optimization suggestions for different types of users, the WebRTC keep-alive parameters include heartbeat interval, retransmission mechanism, balance exploration and utilization through ε-greedy strategy, the reward function is designed as:
[0025] ;
[0026] wherein, λ 1, λ 2, λ 3 is the scene adaptive weight, T c is the connection survival time, C r is the resource consumption, E u is the user interaction efficiency, if it is an active user, then increase λ 1 priority to ensure connection stability; if it is a silent user, then increase balance keep-alive and power consumption; if it is an intermittent user, then dynamically balance λ 1 and λ 2 to avoid frequent retransmission leading to resource waste.
[0027] Further, in step S23, the WebRTC keep-alive parameters dynamically optimized and adjusted for different types of users include heartbeat interval dynamic optimization and retransmission mechanism dynamic adaptation, wherein:
[0028] Heartbeat interval dynamic optimization includes:
[0029] For active users, due to frequent operation, it is determined that there is high connection demand, the heartbeat interval is automatically shortened to ensure real-time response;
[0030] For intermittent users, adjust dynamically according to the behavior interval;
[0031] For silent users, trigger low-power keep-alive mode, extend the heartbeat interval to 5-10 seconds, and reduce data channel bandwidth to reduce resource consumption;
[0032] Retransmission mechanism dynamic adaptation includes:
[0033] For active users, reduce the retransmission delay threshold when the network fluctuates, enable fast retransmission to avoid operation lag;
[0034] For silent users: increase the initial delay and reduce the retry frequency using dynamic exponential backoff algorithm.
[0035] Further, the step S23, the interface optimization suggestion specifically includes interface layout dynamic adjustment and interaction mode adaptation, wherein:
[0036] The interface layout dynamic adjustment includes steps of:
[0037] For active users, according to high-frequency operation behavior, the core function is displayed on top, and the operation path is shortened;
[0038] For intermittent users, when the behavior is intermittent, the non-key module is automatically folded to reduce interface interference;
[0039] For silent users, if the line of sight focuses on a certain area, the interface keeps the current layout but reduces the animation rendering frame rate to save GPU resources;
[0040] The interaction mode adaptation includes steps of:
[0041] For active users, the operation behavior of the user is enabled with a real-time feedback mechanism (such as click animation immediate response);
[0042] For silent users: trigger the do-not-disturb mode, reduce the interface pop-up or sound prompt, and avoid misjudgment as connection failure.
[0043] Further, the interface layout dynamic adjustment further includes steps of:
[0044] Based on the user behavior heat map, the interface element level is dynamically adjusted, wherein the display priority formula of the interface function module is:
[0045] ;
[0046] Wherein, is the click frequency, is the stay time, is the business urgency, S is the total display weight reference value or space proportion factor of the interface layout, ∑( f j . t j + e j is the sum of the click frequency × stay time + business urgency of all interface elements, j is the element index;
[0047] The elastic layout algorithm is introduced, the responsive template is automatically switched according to the device screen size, and the user silence caused by interface operation lag is reduced (so as to reduce the probability of misjudgment as “connection failure”).
[0048] Further, in the step S3, the generated WebRTC keep-alive strategy is executed, operation instructions are sent to the WebRTC, keep-alive data packets are sent through the data channel DataChannel of the WebRTC, and the WebSocket channel is used as a backup to realize channel redundancy when the network fluctuates, specifically including a multi-channel redundancy strategy and a connection reconstruction threshold control, wherein the multi-channel redundancy strategy includes the steps of:
[0049] For active users, the main channel DataChannel and the signaling channel WebSocket of the WebRTC are enabled at the same time to ensure double-link backup and reduce the risk of disconnection.
[0050] For silent users, only the main channel DataChannel is retained to reduce the resource occupation of double channels when the heartbeat interval is extended.
[0051] The connection reconstruction threshold control includes the steps of:
[0052] For active users, the connection reconstruction trigger threshold is reduced to quickly recover the connection.
[0053] For silent users, the connection reconstruction trigger threshold is increased to avoid false triggering of reconstruction due to temporary network fluctuations.
[0054] Another aspect of the present application also provides a WebRTC-based connection keep-alive device, comprising:
[0055] A data acquisition module is configured to acquire network quality data, user operation behavior data, browser performance indicators, and network system parameters in real time, construct a state vector, and the system parameters include a heartbeat interval and a retransmission number.
[0056] A decision generation module is configured to fuse user operation behavior data, network quality data, and interface interaction data, generate interface optimization suggestions and WebRTC keep-alive strategies for different types of users through reinforcement learning, and continuously optimize.
[0057] A decision execution module is configured to execute the generated interface optimization suggestions and WebRTC keep-alive strategies, send operation instructions to the WebRTC, send keep-alive data packets through the data channel DataChannel of the WebRTC, and use the WebSocket channel as a backup to realize channel redundancy when the network fluctuates.
[0058] A data transmission and feedback module is configured to receive the operation instructions through the connection object RTCPeerConnection of the WebRTC, be responsible for audio / video and data transmission, and feed back the adjusted connection state changes and network quality data.
[0059] The application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor implements the steps of the WebRTC-based connection keep-alive method when executing the computer program.
[0060] The application also provides a storage medium, including a stored program, wherein the program controls the device where the storage medium is located to execute the steps of the WebRTC-based connection keep-alive method when running.
[0061] Compared with the prior art, the application has the following beneficial effects:
[0062] The application provides a WebRTC-based connection keep-alive method, device, equipment and medium, which breaks through the limitations of the traditional WebRTC keep-alive mechanism, and constructs a self-adaptive, low-power and high-reliable connection keep-alive system through the deep cooperation of "intelligent analysis of user behavior-real-time perception of network state-dynamic adaptation of interface interaction". The application first integrates multi-modal interaction data into the keep-alive decision, proposes a "user behavior-network state-interface interaction" three-in-one intelligent keep-alive system, and realizes the dynamic regulation and control of the connection state through multi-dimensional data fusion. The application proposes a dynamic strategy optimization framework based on reinforcement learning, realizes the closed-loop iteration of "monitoring-analysis-execution-feedback", and establishes a linkage mechanism between the interface layout and the connection state, indirectly improves the connection activity from the user experience layer, and can be widely applied to the real-time communication field, and provides core technical support for the next generation of intelligent interaction system. BRIEF DESCRIPTION OF DRAWINGS
[0063] The accompanying drawings, which are incorporated into and form part of the specification, illustrate embodiments consistent with the application and, together with the specification, serve to explain the principles of the application.
[0064] In order to more clearly illustrate the technical solutions in the embodiments of the application or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced as follows. Obviously, for those skilled in the art, other drawings can also be obtained based on these drawings without creative labor.
[0065] Figure 1 Schematic diagram of the composition principle of the WebRTC-based connection keep-alive system;
[0066] Figure 2 The application provides a WebRTC-based connection keep-alive method flowchart of the preferred embodiment;
[0067] Figure 3is a schematic diagram of a WebRTC-based connection keep-alive device module of a preferred embodiment of the present application;
[0068] Figure 4 is a schematic block diagram of an electronic device entity of a preferred embodiment of the present application;
[0069] Figure 5 is an internal structure diagram of a computer device of a preferred embodiment of the present application. DETAILED DESCRIPTION
[0070] It should be understood that the specific embodiments described herein are merely intended to explain the technical solutions of the present application, and are not intended to limit the present application.
[0071] In order to better understand the technical solutions of the present application, the following will be described in detail in combination with the drawings of the specification and the specific embodiments.
[0072] It should be noted that the execution subject of the present embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or a WebRTC-based connection keep-alive system capable of realizing the above functions, as shown in Figure 1 The WebRTC-based connection keep-alive system includes:
[0073] User behavior monitoring module
[0074] Function: Collect user operation data in multiple ways, including basic behaviors such as clicking, sliding, keyboard input, and immersive interaction data such as eye tracking, voice instructions, as well as browser performance indicators;
[0075] Action: Convert user behavior into analyzable feature data to provide basis for subsequent decision-making.
[0076] Network state awareness module
[0077] Function: Real-time monitoring of network quality, obtaining parameters such as round-trip delay, packet loss rate, and bandwidth fluctuation, and generating network health assessment results;
[0078] Action: Quantify network environment stability to provide key reference for keep-alive strategy adjustment.
[0079] Interface interaction optimization module
[0080] Function: Dynamically adjust interface layout according to user behavior data, such as optimizing display priority and size of functional modules; at the same time, identify the "effective silence" state of the user (such as focusing on the line of sight but no operation), and trigger the low-power keep-alive mode;
[0081] Action: Improve user interaction efficiency and reduce connection misjudgment caused by interface operation problems.
[0082] Intelligent decision engine
[0083] Function: System core module, integrating user behavior, network status and interface interaction data, clustering algorithm to divide users into different types, combined with network health assessment results to generate keep-alive strategy (such as heartbeat interval, retry mechanism), and continuously optimize the strategy through reinforcement learning;
[0084] Action: Integrating multi-source data, realizing intelligent decision of keep-alive strategy.
[0085] WebRTC keep-alive executor
[0086] Function: Execute the keep-alive strategy generated by the decision engine, send keep-alive data packets through the data channel, and use the WebSocket channel as a backup to realize channel redundancy when the network fluctuates; adopt intelligent retry mechanism, dynamically adjust the retry strategy according to the network status;
[0087] Action: Directly maintain the active state of WebRTC connection.
[0088] RTCPeerConnection connection
[0089] Function: WebRTC core connection object, responsible for audio / video and data transmission; feedback connection state changes and network quality data to the monitoring module, receive operation instructions from the keep-alive executor;
[0090] Action: Bridge connecting various modules, providing real-time state feedback.
[0091] The following takes the WebRTC-based connection keep-alive system as an example to illustrate this embodiment and the following embodiments.
[0092] As shown in Figure 2 , the preferred embodiment of the present application provides a WebRTC-based connection keep-alive method, comprising the steps of:
[0093] S1, real-time collection of network quality data (RTT, packet loss rate), user operation behavior data (eye movement / operation trajectory) and browser performance indicators, network system parameters (heartbeat interval, retransmission times), construction of state vector, the system parameters include heartbeat interval, retransmission times;
[0094] S2, fusion of user operation behavior data, network quality data and interface interaction data, generating interface optimization suggestions, WebRTC keep-alive strategy and continuously optimizing for different operation types of users through reinforcement learning;
[0095] S3, execute the generated interface optimization suggestion, WebRTC keep-alive strategy, send operation instructions to WebRTC, send keep-alive data packets through the data channel DataChannel of WebRTC, and use the WebSocket channel as a backup to realize channel redundancy when the network fluctuates;
[0096] S4, receive the operation instructions through the connection object RTCPeerConnection of WebRTC, and be responsible for audio / video and data transmission and feedback of adjusted connection state changes and network quality data.
[0097] The embodiment provides a WebRTC-based connection keep-alive method, which breaks through the limitations of the traditional WebRTC keep-alive mechanism, and through the deep cooperation of "intelligent analysis of user behavior-real-time perception of network state-dynamic adaptation of interface interaction", a self-adaptive, low-power and high-reliable connection keep-alive system is constructed. The embodiment first integrates multi-modal interaction data into keep-alive decision-making, proposes a "user behavior-network state-interface interaction" three-in-one intelligent keep-alive system, and realizes dynamic regulation and control of connection state through multi-dimensional data fusion; the embodiment proposes a dynamic strategy optimization framework based on reinforcement learning, realizes the closed-loop iteration of "monitoring-analysis-execution-feedback", and thus continuously optimizes the strategy by using the connection state feedback, realizes the continuous improvement of "data-decision-effect", and can dynamically adapt to different scenes, such as shortening the heartbeat interval and enabling the backup channel in a weak network; when the user is silent but the vision is focused, switch to a low-power mode to save resources; the embodiment can dynamically switch the data channel and the WebSocket channel according to the network state by setting multi-channel redundancy, thereby improving the connection stability in a weak network environment and solving the problem that a single channel is easily interrupted in a weak network. The embodiment establishes a linkage mechanism of interface layout and connection state, and the interface layout optimization and keep-alive strategy are coordinated through an intelligent decision engine, so as to reduce the user operation lag and indirectly reduce the connection disconnection rate, thereby indirectly improving the connection activity from the user experience layer, and can be widely applied to the real-time communication field and provide core technical support for the next-generation intelligent interaction system.
[0098] Preferably, in the step S1, the real-time collection of the user operation behavior data specifically comprises the steps of:
[0099] S11, multi-modal data collection: including user operation behavior data and browser performance indicators, the user operation behavior data including basic operation behavior, immersive interaction data and browser performance data, the basic operation behavior including clicking (coordinate + pressure sensing, suitable for touch screen devices), sliding track (acceleration sensor data), keyboard input frequency (keystroke interval entropy value); immersive interaction data includes eye tracking (capturing pupil focus position through camera, accuracy ± 20px), voice command keyword recognition (combining NLP to analyze user intent); browser performance data includes browser memory usage, GPU rendering frame rate monitoring (obtained through performance.memory and requestAnimationFrame interfaces);
[0100] S12, spatiotemporal feature modeling: introducing a time series analysis model (such as LSTM neural network) to construct a user behavior trajectory matrix X for user operation behavior data:
[0101] ;
[0102] wherein, n is the feature dimension;
[0103] S13, weighting the influence factor of different user operation behaviors on connection activity through attention mechanism.
[0104] Preferably, the step S2 specifically comprises the following steps:
[0105] S21, according to the collected user operation behavior data and improved DBSCAN algorithm (introducing spatial density threshold and time decay factor), the user is divided into active type, intermittent type and silent type according to operation type, solving the defect that traditional K-Means needs to preset cluster number, wherein the active type means that the user operates frequently, such as continuously clicking, sliding, keyboard input and other basic operations, or frequently using eye tracking, voice command and other immersive interaction methods, the operation interval is short and has continuity; the intermittent type means that the user operation has obvious interval period, that is, there is active operation behavior in a period of time, followed by a relatively stationary stage, and the operation behavior presents the characteristics of periodic alternation of activity and intermittence; the silent type means that the user's line of sight focuses on a certain area but there is no operation;
[0106] S22, real-time collection of network quality data to construct network health index:
[0107] ;
[0108] wherein, RTT is the round-trip delay, P is the packet loss rate, Δ B bandwidth fluctuation coefficient, ω 1,ω 2、 ω 3 is a corresponding dynamic weight coefficient;
[0109] S23, in combination with user operation behavior data, network health index and interface interaction data, using reinforcement learning Q-Learning for dynamic optimization and adjustment of WebRTC keep-alive parameters and interface optimization suggestions for different types of users, the WebRTC keep-alive parameters include heartbeat interval, retransmission mechanism, through the balance of exploration and utilization of ε-greedy strategy, the reward function is designed as:
[0110] ;
[0111] Wherein, λ 1、 λ 2、 λ 3 is the scene adaptive weight, T c is the connection survival time, C r is the resource consumption, E u is the user interaction efficiency, if it is an active user, then increase λ 1 priority to ensure the stability of the connection; if it is a silent user, then increase balance keep-alive and power consumption; if it is an intermittent user, then dynamically balance λ 1 and λ 2 to avoid frequent retransmission leading to resource waste.
[0112] Preferably, in step S23, the WebRTC keep-alive parameters dynamically optimized and adjusted for different types of users include heartbeat interval dynamic optimization and retransmission mechanism dynamic adaptation, wherein:
[0113] Heartbeat interval dynamic optimization includes:
[0114] For active users, due to frequent operation, it is determined that there is high connection demand, and the heartbeat interval is automatically shortened (such as from the default 5 seconds to 2-3 seconds), to ensure real-time response;
[0115] For intermittent users, the behavior interval is dynamically adjusted (such as maintaining the default heartbeat when the operation gap is 5 seconds, and extending to 8 seconds when there is no operation for 10 seconds);
[0116] For silent users, trigger low-power keep-alive mode, extend the heartbeat interval to 5-10 seconds (such as the "effective silence" scenario mentioned in the document), and reduce the data channel bandwidth to reduce resource consumption;
[0117] Retransmission mechanism dynamic adaptation includes:
[0118] For active users, reduce the retransmission delay threshold when the network fluctuates, enable fast retransmission, and avoid operation lag;
[0119] For silent users: increase the initial delay (such as the formula in the dynamic exponential backoff algorithm Increase) in the dynamic exponential backoff algorithm to increase the retransmission mechanism, and reduce the retry frequency, wherein the dynamic exponential backoff algorithm is an exponential backoff + dynamic threshold algorithm:
[0120] ;
[0121] Where t retry represents the retry delay time, i.e. the time interval between each connection failure and the next retry. The retry delay time is dynamically calculated by the formula, combined with the retry number k, the initial delay and the 0-1 random number rand(), to realize the "exponential backoff" mechanism, avoiding network congestion or resource waste caused by frequent retries. The specific logic is: as the number of retries increases, the delay time increases exponentially, and the random number is introduced to avoid simultaneous retries of multiple connections, improving the connection recovery efficiency in weak network environment.
[0122] When the number of consecutive retries exceeds the threshold (H is the network health index), the connection reconstruction process is automatically triggered.
[0123] Preferably, in the step S23, the interface optimization suggestion specifically includes interface layout dynamic adjustment and interaction mode adaptation, wherein:
[0124] The interface layout dynamic adjustment includes the steps of:
[0125] For active users, according to high-frequency operation behavior, the core function (such as the "share screen" button in video conference) is displayed on top, and the operation path is shortened;
[0126] For intermittent users, when the behavior is intermittent, non-critical modules are automatically folded to reduce interface interference;
[0127] For silent users, if the line of sight is focused on an area (such as reading a document), the interface maintains the current layout but reduces the animation rendering frame rate to save GPU resources;
[0128] The interaction mode adaptation includes the steps of:
[0129] For active users, enable real-time feedback mechanism for user operation behavior (such as immediate response to click animation);
[0130] For silent users: trigger the do-not-disturb mode, reduce the interface pop-up or sound prompt, and avoid misjudgment as connection failure.
[0131] When the generated WebRTC keep-alive strategy is executed, the WebRTC keep-alive executor performs the following operations:
[0132] Multi-channel redundancy strategy
[0133] For active users: enable both DataChannel and WebSocket signaling channels, ensure dual-link backup, and reduce the risk of disconnection;
[0134] For silent users: only keep the main channel (DataChannel), and reduce the resource occupation of dual-channel when the heartbeat interval is extended.
[0135] Connection reconstruction threshold control
[0136] For active users: reduce the connection reconstruction trigger threshold (e.g., set the number of consecutive retries K_max to 5), and quickly recover the connection;
[0137] For silent users: increase the trigger threshold (e.g., set K_max to 10), and avoid false triggering of reconstruction due to temporary network fluctuations.
[0138] Preferably, the interface layout dynamic adjustment further comprises the steps of:
[0139] Based on the user behavior heat map (generated by eye movement data and click trajectory), dynamically adjust the interface element hierarchy, wherein the display priority formula of the interface function module (such as the conference hang-up button) is:
[0140] ;
[0141] wherein, is the click frequency, is the dwell time, is the business urgency, S is the total display weight reference value or space proportion factor of the interface layout, ∑( f j . t j + e j is the sum of the click frequency × dwell time + business urgency of all interface elements, j is the element index;
[0142] An elastic layout algorithm is introduced to automatically switch responsive templates according to the device screen size (monitored by window.innerWidth), reducing user silence caused by interface operation lag (thus reducing the probability of false judgment as "connection failure").
[0143] The dynamic interface of the present application is linked with the keep-alive mechanism. When the interface monitors that the user has been inactive for a long time (e.g., more than 30 seconds), but the heat map shows that the user's gaze is focused on a certain area (e.g., reading conference documents), the system determines that it is "effective silence" and automatically switches to a low-power keep-alive mode (extends the heartbeat interval to 5-10 seconds and reduces the data channel bandwidth).
[0144] Preferably, in the step S3, the generated WebRTC keep-alive strategy is executed, operation instructions are sent to WebRTC, keep-alive data packets are sent through the data channel DataChannel of WebRTC, and the WebSocket channel is used as a backup to realize channel redundancy when the network fluctuates, which specifically includes a multi-channel redundancy strategy and a connection reconstruction threshold control. The multi-channel redundancy strategy includes the following steps:
[0145] For active users, the main channel DataChannel and the signaling channel WebSocket of WebRTC are enabled at the same time to ensure dual-link backup and reduce the risk of disconnection.
[0146] For silent users, only the main channel DataChannel is retained to reduce the resource occupation of dual channels when the heartbeat interval is extended.
[0147] The connection reconstruction threshold control includes the following steps:
[0148] For active users, the connection reconstruction trigger threshold is reduced (e.g., the number of consecutive retries K_max is set to 5), and the connection is quickly recovered.
[0149] For silent users, the connection reconstruction trigger threshold is increased (e.g., K_max is set to 10) to avoid false triggering of reconstruction due to temporary network fluctuations.
[0150] Through testing, the WebRTC-based connection keep-alive method of the present application has the following advantages:
[0151] Intelligent improvement: through behavior-network two-dimensional modeling, the accuracy of the keep-alive strategy is improved by more than 40% compared with traditional schemes, specifically:
[0152] Intelligent improvement: through multi-modal behavior data collection (eye tracking + voice command NLP + keyboard input entropy), an n-dimensional feature matrix is constructed, combined with LSTM neural network and attention mechanism for spatiotemporal trajectory modeling, and real-time collection of RTT / packet loss rate / bandwidth fluctuation to construct a dynamic network health index H. After improving the DBSCAN algorithm to classify users into three categories, Q-Learning reinforcement learning strategy is matched to form a "behavior-network" two-dimensional closed-loop regulation. Among them:
[0153] Eye movement data identifies "effective silence" to reduce false positives by 20%;
[0154] Network health index drives weak network strategy adjustment, increasing connection success rate by 24%;
[0155] Dynamic interface layout shortens operation path by 35%, indirectly reducing silent false positives by 15%;
[0156] Reinforcement learning continues to iterate, reducing policy adaptation error accumulation by 30%.
[0157] Under the synergistic effect of multiple technology modules, the accuracy of keep-alive strategy self-adaptation is improved by more than 40% compared with traditional solutions.
[0158] Resource utilization optimization: In strong network scenarios, the heartbeat interval can be extended to 20 seconds (traditional solution fixed at 5 seconds), saving bandwidth consumption by 30%-50%, specifically:
[0159] Resource utilization optimization: In strong network scenarios, through dynamic assessment of network health index H (RTT < 50ms, packet loss rate < 1%), combined with improved DBSCAN user classification and Q-Learning reinforcement learning, the heartbeat interval can be adaptively extended to 20 seconds (traditional solution fixed at 5 seconds). This strategy uses WebSocket signaling channel to back up DataChannel, and adjusts the dynamic threshold value of the exponential backoff retry algorithm, which reduces the bandwidth consumption from 50KB / minute in the traditional solution to 10KB / minute, saving 30%-50% under the premise of ensuring connection reliability.
[0160] User experience enhancement: Dynamic interface layout shortens the operation path of core functions by 35%, reducing the false touch rate by 28%;
[0161] Weak network adaptability: In a network environment with a packet loss rate of 20%, the connection success rate is improved from 65% to 89%, specifically:
[0162] Dual-signaling channel redundant transmission: Based on DataChannel, WebSocket long connection backup keep-alive signaling is added, and another channel is automatically supplemented when a single channel loses packets. When the traditional single-channel packet loss rate is 20%, the signaling success rate is only 80%, and when the dual-channel parallel loses packets, the probability is reduced to 4%, and the signaling success rate is increased to 96%.
[0163] Intelligent retry strategy optimization: using the "exponential backoff + dynamic threshold" algorithm, the retry delay increases exponentially with the number of times (e.g. 1st 100ms, 2nd 200ms + random value), avoiding network congestion; at the same time, according to the network health index, the retry threshold is dynamically adjusted (from the traditional fixed 3 times to 8 times), the number of connection recovery attempts increases by 60%.
[0164] Network state dynamic optimization: real-time collection of RTT, packet loss rate, etc. to build a health index, automatically shorten the heartbeat interval to 2 seconds when the packet loss rate is 20%, and enable fast retransmission mechanism to reduce the impact of signaling loss.
[0165] Behavioral data anti-misjudgment: through eye tracking, keyboard input and other multi-modal data, distinguish "network packet loss" and "user silence", avoid false triggering of disconnection due to temporary packet loss, and reduce the misjudgment rate from 15% to less than 5%.
[0166] Comprehensive mechanism: signaling success rate increased by 16% (80% to 96%), retry times increased by 60% (3 times to 8 times), misjudgment rate reduced by 10% (15% to 5%), combined with dynamic optimization of weak network parameters, ultimately increased the connection success rate from 65% to 89%.
[0167] The keep-alive method provided by the application can be applied to the following application scenarios:
[0168] Remote medical care: in remote diagnosis of ultrasound images, the dynamic keep-alive mechanism can avoid image transmission interruption caused by network fluctuations, and combined with interface optimization to ensure that doctors can quickly access measurement tools;
[0169] Industrial Internet of Things: in the remote device control scene, the behavior monitoring identifies the operation habits of engineers, automatically adjusts the control panel layout, and enables low-latency keep-alive mode when the network is unstable;
[0170] Meta-universe social: in virtual space, dynamically adjust the interaction interface according to user body movements (captured by camera), and maintain real-time connection in high-concurrency scenarios.
[0171] As shown in Figure 3 Another aspect of the application also provides a WebRTC-based connection keep-alive device, comprising:
[0172] A data acquisition module is configured to collect network quality data (RTT, packet loss rate), user operation behavior data (eye movement / operation trajectory) and browser performance indicators, network system parameters (heartbeat interval, retransmission times) in real time, and construct a state vector, wherein the system parameters include heartbeat interval and retransmission times.
[0173] A decision generation module is configured to fuse user operation behavior data, network quality data and interface interaction data, and generate interface optimization suggestions, WebRTC keep-alive strategies for users of different operation types and continuously optimize through reinforcement learning.
[0174] A decision execution module is configured to execute the generated interface optimization suggestions and WebRTC keep-alive strategies, send operation instructions to WebRTC, send keep-alive data packets through a data channel DataChannel of WebRTC, and use a WebSocket channel as a backup to realize channel redundancy when the network fluctuates.
[0175] A data transmission and feedback module is configured to receive the operation instructions through a connection object RTCPeerConnection of WebRTC, and is responsible for audio / video and data transmission and feedback of adjusted connection state changes and network quality data.
[0176] The WebRTC-based connection keep-alive device provided by the application adopts the WebRTC-based connection keep-alive method in the above embodiment, which can solve the technical problems that the existing keep-alive technology cannot cope with network fluctuations, power consumption and traffic consumption, cannot adapt to user personalized operation habits, and cannot dynamically adjust the keep-alive strategy. Compared with the prior art, the WebRTC-based connection keep-alive device provided by the application has the same beneficial effects as the WebRTC-based connection keep-alive method provided by the above embodiment, and other technical features in the WebRTC-based connection keep-alive device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0177] As shown in Figure 4 The preferred embodiment of the application further provides an electronic device, which includes a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the WebRTC-based connection keep-alive method in the above embodiment when executing the computer program.
[0178] The electronic device provided by the application adopts the WebRTC-based connection keep-alive method in the above embodiment, which can solve the technical problems that the existing keep-alive technology cannot cope with network fluctuations, power consumption and traffic consumption, cannot adapt to user personalized operation habits, and cannot dynamically adjust the keep-alive strategy. Compared with the prior art, the electronic device provided by the application has the same beneficial effects as the WebRTC-based connection keep-alive method provided by the above embodiment, and other technical features in the electronic device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0179] As shown in Figure 5As shown, a preferred embodiment of this application also provides a computer device, which may be a terminal or a liveness detection server, and its internal structure diagram may be as follows. Figure 5 As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage medium. The network interface is used to communicate with other external computer devices via a network connection. When the computer program is executed by the processor, it implements the steps of the WebRTC-based connection keep-alive method described above.
[0180] Those skilled in the art will understand that Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0181] The computer device provided in this application, employing the WebRTC-based connection keep-alive method described in the above embodiments, can solve the technical problems of existing keep-alive technologies being unable to cope with network fluctuations in power and data consumption, unable to adapt to users' personalized operating habits, and unable to dynamically adjust keep-alive strategies. Compared with the prior art, the beneficial effects of the computer device provided in this application are the same as those of the WebRTC-based connection keep-alive method provided in the above embodiments, and other technical features in the electronic device are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0182] A preferred embodiment of this application also provides a storage medium, the storage medium including a stored program, which, when the program is executed, controls the device where the storage medium is located to perform the steps of the WebRTC-based connection keep-alive method in the above embodiments.
[0183] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0184] If the functions of the method in the embodiments are implemented in the form of software function units and sold or used as independent products, the software function units can be stored in one or more computer readable storage media. Based on such understanding, the part of the prior art or the part of the technical solutions of the embodiments of the present application that make contributions to the prior art can be embodied in the form of a software product, which is stored in a storage medium, and includes a number of instructions for causing a computer (which can be a personal computer, a server, a mobile computing device, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.
[0185] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage, etc.) containing computer-usable program code. The solutions in the embodiments of the present application can be implemented in various computer languages, such as the object-oriented programming language Java and the interpreted scripting language JavaScript.
[0186] The present application is described with reference to flowcharts and / or block diagrams according to the methods, devices (systems), and computer program products of the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device that implements the functions specified in the flowcharts and / or block diagrams. Figure 1 The functions specified in one flow or multiple flows and / or blocks Figure 1 The functions specified in one flow or multiple flows and / or blocks
[0187] These computer program instructions can also be stored in a computer readable storage medium that can direct the computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable storage medium produce a manufactured product including instruction devices that implement the functions specified in the flowcharts and / or block diagrams. Figure 1 The functions specified in one flow or multiple flows and / or blocks Figure 1the function specified in the one or more blocks.
[0188] These computer program instructions can also be loaded into computer or other programmable data processing devices, so that a series of operation steps are performed on the computer or other programmable data processing devices to generate computer-implemented processes, so that the instructions executed on the computer or other programmable data processing devices provide processes for implementing the flowcharts Figure 1 one or more flows and / or blocks Figure 1 the steps of the function specified in the one or more blocks.
[0189] The application also provides a computer program product comprising a computer program, which, when executed by a processor, implements the steps of the WebRTC-based connection keep-alive method as described above.
[0190] The computer program product provided by the application can solve the technical problems that the existing keep-alive technology cannot cope with network fluctuations, cannot adapt to user personalized operation habits, and cannot dynamically adjust the keep-alive strategy. Compared with the prior art, the beneficial effects of the computer program product provided by the application are the same as those of the WebRTC-based connection keep-alive method provided by the above-mentioned embodiments, and are not described here.
[0191] Although the preferred embodiments of the application have been described, those skilled in the art who understand the basic inventive concept can make additional changes and modifications to these embodiments. Therefore, the appended claims are intended to include the preferred embodiments and all changes and modifications falling within the scope of the application.
[0192] Obviously, those skilled in the art can make various modifications and variations to the application without departing from the spirit and scope of the application. Thus, if these modifications and variations of the application fall within the scope of the claims of the application and their equivalent technologies, the application also intends to include these modifications and variations.
Claims
1. A connection keep-alive method based on WebRTC, characterized in that, Including the following steps: S1. Real-time collection of network quality data, user operation behavior data, browser performance indicators, and network system parameters to construct a state vector. The system parameters include heartbeat interval and retransmission count. S2. Integrate user operation behavior data, network quality data, and interface interaction data. Through reinforcement learning, generate interface optimization suggestions and WebRTC keep-alive strategies for users with different operation types and continuously optimize them. Specific steps include: S21. Based on the collected user operation behavior data and the improved DBSCAN algorithm, users are classified into active, intermittent, and silent types according to their operation type. S22. Real-time collection of network quality data to construct a network health index: H = ω1·RTT + ω2·P + ω3·ΔB Where RTT is the round-trip time, P is the packet loss rate, ΔB is the bandwidth fluctuation coefficient, and ω1, ω2, and ω3 are the corresponding dynamic weight coefficients. S23. Combining user operation behavior data, network health index, and interface interaction data, reinforcement learning Q-Learning is used to dynamically optimize and adjust WebRTC keep-alive parameters and interface optimization suggestions for different types of users. The WebRTC keep-alive parameters include heartbeat interval and retransmission mechanism. An ε-greedy strategy is used to balance exploration and utilization, and the reward function is designed as follows: R=λ1·T C -λ2·C r +λ3·E u Where λ1, λ2, and λ3 are scene adaptive weights, and T c For connection lifetime, C r For resource consumption, E u To improve user interaction efficiency, for active users, increase λ1 to prioritize connection stability; for silent users, increase λ3 to balance keep-alive and power consumption; for intermittent users, dynamically balance λ1 and λ2 to avoid resource waste caused by frequent retransmissions. S3. Execute the generated interface optimization suggestions and WebRTC keep-alive strategy, send operation instructions to WebRTC, send keep-alive data packets through the WebRTC data channel DataChannel, and use the WebSocket channel as a backup to achieve channel redundancy when the network fluctuates. S4. Receive the operation instructions through the WebRTC connection object RTCPeerConnection, be responsible for audio, video and data transmission, and provide feedback on the adjusted connection status changes and network quality data.
2. The WebRTC-based connection keep-alive method according to claim 1, characterized in that, Step S1, which involves real-time collection of user operation behavior data, specifically includes the following steps: S11. Multimodal data acquisition: including user operation behavior data and browser performance indicators. The user operation behavior data includes basic operation behavior, immersive interaction data and browser performance data. The basic operation behavior includes clicks, swipe trajectories and keyboard input frequency. The immersive interaction data includes eye tracking and voice command keyword recognition. The browser performance data includes browser memory usage and GPU rendering frame rate monitoring. S12. Spatiotemporal Feature Modeling: Introducing a time series analysis model to construct a user behavior trajectory matrix X from user operation behavior data: In the formula, n is the feature dimension; S13. Weight the impact factors of different user operation behaviors on connection activity through attention mechanism.
3. The WebRTC-based connection keep-alive method according to claim 1, characterized in that, In step S23, the WebRTC keep-alive parameters obtained by dynamically optimizing and adjusting different types of users include dynamic optimization of heartbeat interval and dynamic adaptation of retransmission mechanism, wherein: Dynamic optimization of heart rate interval includes: For active users, due to frequent operations, a high connection demand is identified, and the heartbeat interval is automatically shortened to ensure real-time response. For intermittent users, the settings are dynamically adjusted based on the intervals between behaviors. For silent users, a low-power keep-alive mode is triggered, with the heartbeat interval extended to 5-10 seconds, while reducing data channel bandwidth and resource consumption. Dynamic adaptation of retransmission mechanisms includes: For active users, reduce the retransmission latency threshold and enable fast retransmission when the network fluctuates to avoid operation lag. For silent users: When using the dynamic exponential backoff algorithm to obtain a retransmission mechanism, the initial delay is increased and the retry frequency is reduced.
4. The WebRTC-based connection keep-alive method according to claim 1, characterized in that, In step S23, the interface optimization suggestions specifically include dynamic adjustment of the interface layout and adaptation of the interaction mode, wherein: The dynamic adjustment of the interface layout includes the following steps: For active users, core functions are displayed at the top based on high-frequency operation behaviors, shortening the operation path; For intermittent users, non-critical modules are automatically collapsed when an intermittent behavior is detected to reduce interface interference; For silent users, if their gaze is focused on a certain area, the interface maintains the current layout but reduces the animation rendering frame rate to save GPU resources; The interaction mode adaptation includes the following steps: For active users, a real-time feedback mechanism is enabled for user actions; For silent users: Trigger Do Not Disturb mode to reduce interface pop-ups or sound prompts and avoid misjudging connection failure.
5. The WebRTC-based connection keep-alive method according to claim 4, characterized in that, The dynamic adjustment of the interface layout also includes the following steps: Based on user behavior heatmaps, the hierarchy of interface elements is dynamically adjusted. The formula for the display priority of interface functional modules is as follows: Among them, f i For click frequency, t i e represents the duration of stay. i For business urgency, S is the baseline value of the total display weight of the interface layout or the space ratio factor, ∑(f j .t j +e j ) is the sum of click frequency × dwell time + business urgency of all interface elements, and j is the element index; A flexible layout algorithm is introduced to automatically switch responsive templates based on the device screen size, reducing user silence caused by interface lag.
6. The WebRTC-based connection keep-alive method according to claim 1, characterized in that, In step S3, the generated WebRTC keep-alive strategy is executed, an operation command is sent to WebRTC, and keep-alive data packets are sent through the WebRTC data channel DataChannel. Simultaneously, the WebSocket channel is used as a backup to achieve channel redundancy during network fluctuations. Specifically, this includes a multi-channel redundancy strategy and connection reconstruction threshold control. The multi-channel redundancy strategy includes the following steps: For active users, both the main WebRTC channel (DataChannel) and the signaling channel (WebSocket) are enabled simultaneously to ensure dual-link backup and reduce the risk of connection failure. For silent users, only the main channel DataChannel is retained to reduce the resource consumption of dual channels when the heartbeat interval is extended; The connection reconstruction threshold control includes the following steps: For active users, lower the connection rebuild trigger threshold to quickly restore the connection; For silent users, increase the connection reconstruction trigger threshold to avoid accidental reconstruction due to brief network fluctuations.
7. A WebRTC-based connection keep-alive device, characterized in that, include: The data acquisition module is used to collect network quality data, user operation behavior data, browser performance indicators, and network system parameters in real time, and construct a state vector. The system parameters include heartbeat interval and retransmission count. The decision generation module integrates user action behavior data, network quality data, and interface interaction data. Through reinforcement learning, it generates interface optimization suggestions and WebRTC keep-alive strategies for users with different action types and continuously optimizes them. Specifically, it is used for: Based on the collected user operation behavior data and the improved DBSCAN algorithm, users are divided into active, intermittent, and silent types according to their operation type. Real-time collection of network quality data to construct a network health index: H = ω1·RTT + ω2·P + ω3·ΔB Where RTT is the round-trip time, P is the packet loss rate, ΔB is the bandwidth fluctuation coefficient, and ω1, ω2, and ω3 are the corresponding dynamic weight coefficients. Combining user behavior data, network health index, and interface interaction data, reinforcement learning Q-Learning is used to dynamically optimize and adjust WebRTC keep-alive parameters and interface optimization suggestions for different types of users. The WebRTC keep-alive parameters include heartbeat interval and retransmission mechanism. An ε-greedy strategy is used to balance exploration and utilization, and the reward function is designed as follows: R=λ1·T C -λ2·C r +λ3·E u Where λ1, λ2, and λ3 are scene adaptive weights, and T c For connection lifetime, C r For resource consumption, E u To improve user interaction efficiency, for active users, increase λ1 to prioritize connection stability; for silent users, increase λ3 to balance keep-alive and power consumption; for intermittent users, dynamically balance λ1 and λ2 to avoid resource waste caused by frequent retransmissions. The decision execution module is used to execute the generated interface optimization suggestions and WebRTC keep-alive strategy, send operation instructions to WebRTC, send keep-alive data packets through the WebRTC data channel DataChannel, and use the WebSocket channel as a backup to achieve channel redundancy when the network fluctuates. The data transmission and feedback module is used to receive the operation instructions through the WebRTC connection object RTCPeerConnection, and is responsible for audio, video and data transmission and feedback of the adjusted connection status changes and network quality data.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the WebRTC-based connection keep-alive method as described in any one of claims 1 to 6.
9. A storage medium comprising a stored program, characterized in that, When the program is running, it controls the device where the storage medium is located to perform the steps of the WebRTC-based connection keep-alive method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Dynamic self-adapting method for connection of Web RTC (Real Time Communication) client
CN103945003A
Multi-terminal video display adaptive method based on hierarchical traffic prediction
CN120378655A