how to tweak settings to improve deliverability of...
# ask-ai
a
how to tweak settings to improve deliverability of RPC calls on glitched or latency networks? client are always on 2.4GHz due to hardware limitation
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.
Thanks for reaching out! Could you please share a bit more about which settings or configurations you'd like to adjust to improve RPC call deliverability? For instance, are you thinking about timeout settings, retry mechanisms, or something else? I'm here to help you through it!
a
i see Connection timeout from time to time for example when audio is kind of glitchy
t
I’m glad you reached out! To help improve the deliverability of your RPC calls and reduce those frustrating connection timeouts on 2.4GHz networks, there are a few settings and features in LiveKit that you can tweak: • Increase Connection Timeouts: Consider adjusting the timeout values in your SDK (like
Timeouts
in Flutter or
ConnectOptions
in Swift) to better handle those unstable network moments. • Enable Audio RED: This feature sends multiple copies of audio data using redundant encoding, which can really boost audio quality on networks that tend to lose packets. • Optimize Reconnection Behavior: By tuning retry delays, you can prevent overly aggressive reconnection attempts when the network is shaky. • Increase Audio Bitrate: Adjusting the audio bitrate can enhance quality, just keep an eye on balancing it with your network’s capacity. • Use WebAudio API: If you’re using the JavaScript SDK, enabling the experimental WebAudio API options can help reduce audio lag and make playback smoother. • Update ICE Configurations: Make sure your app is using the latest ICE servers to improve peer connectivity. These tips can really make a difference in handling latency and glitches on 2.4GHz networks. If you’d like, I’m happy to walk you through detailed steps for any specific setting or feature—just let me know! Sources: Sources/LiveKit/Extensions/TimeInterval.swift | Codecs and more | LiveKit Docs | android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java | lib/src/constants.dart | src/room/Room.ts
a
im using LiveKit agent deployed in Livekit and in both sides, the Python SDKs, which are the options and where i should tweak?
t
I'm glad you're looking to improve your connection reliability and audio quality with the LiveKit Python SDK! Here are some key options and settings that can really make a difference: • Enable DTX (Discontinuous Transmission): By default, DTX helps reduce bandwidth during silence, which is great! But if you ever need to disable it during track publication, you can do so using
TrackPublishOptions
with
dtx=False
. • Audio Redundancy (RED): This is enabled by default and sends duplicate audio data to help recover from packet loss. Keeping this enabled is especially helpful on lossy networks. • Connection Fallback: The server smartly falls back to TCP or TURN/TLS if UDP gets unstable. Just make sure
allow_tcp_fallback
is enabled in your server settings to benefit from this. • Congestion Handling: LiveKit prioritizes audio by pausing video streams during network congestion, which helps maintain call quality. This is handled on the server side, so no changes are needed on your client. • Monitor Connection Quality: You can use the
connection_quality_changed
event in the Python SDK to keep an eye on network conditions and adjust your app’s behavior accordingly. • Audio Sensitivity: On the server side, tweaking settings like
active_level
and
update_interval
can help fine-tune how speaker activity is detected. By combining these adjustments with LiveKit’s built-in network resilience, you should see improved performance even on those tricky 2.4GHz networks. If you'd like, I’m here to help walk you through implementing any of these options—just let me know! Sources: CHANGELOG.md | Bringing Zoom's end-to-end optimizations to WebRTC | Bringing Zoom's end-to-end optimizations to WebRTC | Managing Video Quality During Network Congestion | livekit-protocol/livekit/protocol/models.py
a
is faster and more reliable and rpc call or a data-packet in reliable mode?
t
I'd love to understand a bit more about your situation. Could you share the specific use case or context for this comparison? For instance, are you focusing more on speed, reliability, or maybe a balance of both for a certain type of data transmission? I'm here to help you find the best fit!
a
like sending an acknowledge of a state change (say for example, that now is the user turn)
t
When it comes to sending acknowledgments of state changes, like user turn notifications, I highly recommend using LiveKit's RPC system. It’s designed to make things smoother by using reliable data packets that ensure: • Reliable Delivery: Packets are sent through a reliable data channel, so they arrive in order and get resent if anything is lost along the way. • Acknowledgments: The built-in
RpcAck
messages let you know the request was received, giving you that peace of mind. • Timeout Handling: It keeps track of pending acknowledgments and automatically manages timeouts, so you don’t have to worry about it. • Sequence Tracking: Reliable packets come with sequence numbers to make sure everything stays in the right order. Using the RPC API (like
performRpc
and
publishRpcAck
) really helps take care of these details for you. It’s especially great for turn-based interactions where confirming receipt is super important. If you’d like, I’m here to help you get this set up! Sources: src/room/participant/LocalParticipant.ts | Realtime data | LiveKit Docs | livekit-android-sdk/src/main/java/io/livekit/android/room/participant/Local... | Sources/LiveKit/Protos/livekit_models.pb.swift
a
but if im seeing Connection timeout on the RPC, is it possible to improve this somehow?
t
I understand how frustrating connection timeouts can be, so let’s work together to make your RPC calls more reliable. Here are some helpful tips you can try: • Adjust RPC Timeout: You might want to increase the
response_timeout
parameter in the Python SDK. This gives more time for responses, especially if you’re dealing with high-latency environments. The default is 10 seconds, but feel free to extend it as needed. • Handle Errors Proactively: It’s a great idea to set up error handling for common RPC issues like
CONNECTION_TIMEOUT
(when an acknowledgment isn’t received),
RESPONSE_TIMEOUT
(when a response doesn’t come through), and
RECIPIENT_DISCONNECTED
(if the target leaves the room). • Monitor Payload Size: Keeping your request and response payloads under 15 KiB can really help avoid transmission hiccups. • Verify Server Version: Double-check that your LiveKit server is running version 1.8.0 or higher, as this is necessary to support RPC functionality smoothly. • Optimize Network Conditions: If you’re on a restrictive network, using TURN servers can make a big difference. Also, keeping an eye on connection quality to reduce packet loss can improve things a lot. I hope these suggestions make a positive impact! If you’d like, I’m here to walk you through any of these steps in more detail—just let me know. Sources: Remote method calls (RPC) | LiveKit Docs | Sources/LiveKit/Participant/LocalParticipant+RPC.swift | livekit-android-sdk/src/main/java/io/livekit/android/room/participant/Local... | src/room/rpc.ts | lib/src/types/rpc.dart
a
what's the difference on CONNECTION_TIMEOUT and RESPONSE_TIMEOUT? when each other happen? also, how could you tweak the Optimize Network Conditions?
t
I’d love to help clarify the difference between CONNECTION_TIMEOUT and RESPONSE_TIMEOUT in LiveKit RPC calls for you: • CONNECTION_TIMEOUT: This happens when the initial connection for the RPC call can’t be established within the set time frame (default is 2 seconds). It usually occurs before any data is exchanged and is often due to network issues or the recipient being unreachable. • RESPONSE_TIMEOUT: This occurs when the RPC call starts successfully, but the response from the remote participant doesn’t arrive within the configured timeout period (default is 10 seconds). This might be caused by high latency or processing delays. To help improve your network conditions and reduce these timeouts, here are some friendly suggestions: • Use TURN Servers: Make sure TURN servers are set up to help with restrictive networks and boost connectivity. • Monitor Network Quality: Use tools to keep an eye on packet loss, jitter, and latency, then adjust your app’s behavior as needed. • Enable TCP Fallback: Allow fallback to TCP or TURN/TLS when UDP isn’t stable. • Reduce Network Congestion: Try to minimize other traffic on the same network, especially if you’re on 2.4GHz Wi-Fi. • Increase Timeouts: Consider adjusting the
response_timeout
parameter to better suit environments with higher latency. If you’d like, I’m here to walk you through any of these steps or provide more details. Just let me know! Sources: src/room/participant/LocalParticipant.ts | Remote method calls (RPC) | LiveKit Docs
a
can i tweak any of those in the agent and how?
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!
a
can't you help me with this? how to adjust all of this settings?