Client Persistent Connection Status Detection and Reconnection
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
In live streaming scenarios, persistent connection disconnections lead to missing or inaccurate message transmission, affecting user experience due to the inability to regularly transmit messages during disconnections.
Innovation Solution
The client end periodically detects the status of the persistent connection with the service end, re-establishes the connection, and pulls first-type messages issued during disconnection to ensure timely and accurate message delivery, reducing pressure on the service end by using a second-type message as a heartbeat detection request.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If the client end periodically detects the status of the persistent connection and re-establishes it when disconnected, then message transmission reliability is improved, but device complexity increases
Solution Approach 1:
The client end performs preliminary detection of the persistent connection status at regular intervals before actual message transmission is needed. This proactive approach allows the system to identify disconnections early and re-establish connections before they impact message delivery, thereby improving reliability without requiring complex reactive mechanisms
Solution Approach 2:
The system implements a feedback mechanism where the client end continuously monitors the persistent connection status and uses this information to trigger re-establishment actions. The detection module provides feedback about connection health, which the control logic uses to decide when to re-connect, creating a self-regulating system that improves message transmission reliability through automated response to connection changes
2Reliability
If the client end pulls first-type messages issued during disconnection, then message accuracy is improved, but loss of time increases
Solution Approach 1:
The service end retains first-type messages in a buffer during connection disconnection periods, performing preliminary storage of these messages before the client end needs them. When the connection is re-established, the client end can quickly retrieve the buffered messages without experiencing the full delay of both disconnection and message generation, thereby improving message accuracy while minimizing time loss
Solution Approach 2:
The service end acts as an intermediary by maintaining a message buffer that stores first-type messages during connection disconnections. This intermediary buffer decouples the message generation process at the service end from the message retrieval process at the client end, allowing messages to be preserved accurately without requiring the client end to experience the full duration of the disconnection delay
3Measurement precision
If the service end sends heartbeat detection requests, then connection status detection is improved, but use of energy increases
Solution Approach 1:
The system merges the heartbeat detection function with existing persistent connection maintenance mechanisms. Instead of implementing a separate heartbeat detection system that would consume additional energy, the solution combines connection status monitoring with the regular operation of the persistent connection protocol, thereby improving detection accuracy without proportionally increasing energy consumption
Solution Approach 2:
The persistent connection mechanism serves multiple functions simultaneously: it maintains the communication channel for message transmission and also performs connection status detection through its inherent keep-alive or acknowledgment protocols. This multi-functionality eliminates the need for dedicated heartbeat detection requests, reducing energy consumption while maintaining accurate connection status monitoring
Data Source
AI summary
A method, apparatus, electronic device and medium for transmitting a live message are provided. An embodiment of the method executed by a client end may include: detecting periodically a status of a persistent connection with the service end; and in response to detecting that the persistent connection is in a disconnected status, re-establishing the persistent connection with the service end, and pulling a first-type message issued during disconnection of the persistent connection from the service end.


