when ConnectionQuality changes to "QUALITY_POOR", ...
# ask-ai
a
when ConnectionQuality changes to "QUALITY_POOR", what are good measures we can take? for example, what's a good level to adjust the timeout or retry attempts? should we auto-disconnect?
t
Thanks for reaching out, Sebastián. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Could you please share a bit more about your use case? For instance, are you hoping to improve the user experience when the connection isn’t great, or maybe looking to manage server resources more efficiently? Understanding this will really help me suggest the best steps, like tweaking timeouts, retries, or auto-disconnect settings. I’m here to help you find the perfect solution!
a
improve the UX and better inform the system status to the user, given that the connection isn't great and delays or packet loss is expected
t
I completely understand how important it is to keep your users informed and comfortable, especially when connection quality isn’t at its best. Here are some thoughtful steps you can take to enhance the experience: • Display Connection Quality: Consider using LiveKit's
ConnectionQuality
indicator to gently show the current connection status (like Excellent, Good, Poor, Lost) right in your UI. Simple touches like color-coded badges or labels such as "Poor" or "Reconnecting" can really help users feel aware and reassured during network hiccups. • Automatic Video Pausing: It’s a great idea to enable video pausing during network congestion while keeping audio flowing smoothly. This way, the experience stays stable with minimal disruption. You can listen for the
trackStreamStateChanged
event to know exactly when video pauses or resumes, so your app can respond thoughtfully. • Custom UI Feedback: When video does pause, offering clear visual cues can make a big difference. You might show a placeholder, display the last video frame with an overlay, or add subtle effects like grayscale or blur to frozen video tiles—this helps users understand what’s happening without confusion. • Improve Responsiveness: Keeping an eye on connection states (such as
room.connect
and
room.connectionState
) and gently notifying users about progress or any setbacks can really ease their minds. Plus, allowing retries instead of leaving them stuck in limbo shows you care about their experience. • Telemetry and Monitoring: Leveraging LiveKit's connection quality scoring, which takes into account packet loss, jitter, RTT, and bitrate, lets you stay ahead of network issues and react proactively, ensuring smoother sessions for everyone. By thoughtfully implementing these steps, you’ll be creating a more reliable and comforting experience for your users—even when the network isn’t cooperating. If you have any questions or want to explore these ideas further, I’m here to help! Sources: Sources/LiveKit/Types/ConnectionQuality.swift | examples/nextjs/pages/customize.tsx | Multiplatform/Views/ParticipantView.swift | agent-console/app/_components/participant-viewer.tsx | Managing Video Quality During Network Congestion
a
on Python Client, what's a good approach
t
I understand how frustrating poor connection quality can be, so let me guide you through some helpful ways to handle this using the Python client: • Monitor Connection Quality: Keep an eye on the
ConnectionQualityChanged
event in the
RoomEvent
class. This lets you track connection quality changes with states like POOR, GOOD, EXCELLENT, and LOST, which can really help you decide the best way to respond. • Automatic Video Pausing: You can enable the "Allow pausing videos when subscribers are congested" option in your project settings. This way, the server will automatically pause video streams during congestion but keep the audio flowing. Plus, you can use the
stream_state_update
event to know exactly when streams are paused or resumed. • Connection Diagnostics: It’s a great idea to use the Connection Test utility to diagnose any issues. Running checks for WebRTC connectivity, WebSocket connectivity, and TURN server connectivity can help you ensure everything is running smoothly. • Connection State Monitoring: The
ConnectionStateChanged
event is your friend here. It helps you handle connection state changes, like when the connection is lost or reconnected, so you can react accordingly. • Quality Scoring: Connection quality is scored based on packet loss, RTT, and jitter. Since packet loss has the biggest impact, focusing on reducing it will really boost the user experience. By following these steps, you’ll be well-equipped to manage poor connection quality and keep your users happy with a stable experience. If you have any questions along the way, feel free to ask—I’m here to help! Sources: CHANGELOG.md | Managing Video Quality During Network Congestion | livekit-protocol/livekit/protocol/models.pyi | Diagnosing Connection Errors with Connection Test Utility
a
i see many "Connection quality changed" event continuously, is there a way to properly handle that?
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!