I have self hosted the livekit server and sip serv...
# ask-ai
r
I have self hosted the livekit server and sip server and hosted the agent on gcp vm. I have done sip trunking with exotel and experiencing latency issues how can I solve it
t
Thanks for reaching out, Rahul. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To help you tackle the latency issues with your self-hosted LiveKit and SIP server setup using Exotel, here are some friendly suggestions you might find useful: • Geographic Proximity: Try placing your servers closer to both your end users and Exotel's SIP endpoints. This can really help cut down on network round-trip time. • Use UDP Transport: Setting your SIP trunk to use UDP for signaling and media often results in lower latency compared to TCP or TLS. • Open Required Ports: Make sure UDP port 5060 (for SIP) and the RTP media range (10000–20000) are open in your firewall and properly forwarded to your SIP server. • Disable Unnecessary Media Encryption: If you don’t need end-to-end encryption, consider setting
media_encryption: SIP_MEDIA_ENCRYPT_DISABLE
in your SIP trunk configuration to lighten the processing load. • Monitor Logs and Metrics: Turning on debug logging in your SIP server can give you valuable insights into call setup times and media path performance, helping you spot where delays might be happening. To get a clearer picture and assist you better, could you please share: • Are you currently using UDP or TCP/TLS for SIP signaling and RTP media? • Have you checked the network latency between your SIP server and Exotel’s SIP endpoints with tools like
ping
or
traceroute
? • Is the latency showing up during call setup (signaling delay) or within the audio stream itself (media delay)? Sources: CHANGELOG.md | SIP overview | LiveKit Docs | test/integration/sip_test.go | Self-hosted SIP server | LiveKit docs | lib/livekit/proto/livekit_sip_pb.rb
r
TCP, it is within the audio stream itself. gemini realtime api is taking to respond and whatever I say is received after 2-3 seconds
t
To help with the latency in your audio stream and the delay in Gemini Realtime API responses, here are some friendly recommendations you might find useful: • Switch Media Transport to UDP: While TCP works well for SIP signaling, using UDP for media transport can really help lower latency. Try configuring your SIP trunk and LiveKit to prioritize UDP for RTP media. • Optimize Audio Chunk Size: Processing audio in 50ms chunks (16kHz, mono) can make a big difference in reducing pipeline delays. • Pre-Resample Audio: Converting audio to 16kHz mono before sending it to LiveKit helps avoid extra resampling overhead on the fly. • Disable Server-Side Turn Detection: If your client is already handling voice activity detection (VAD), turning off server-side turn detection can cut down on processing delays. • Use Optimized AI Models: Setting the Gemini Realtime API to use simpler models like
gemini-2.0-flash-live-001
and limiting response length with
max_output_tokens
can improve performance. • Enable Opus DTX: Make sure Opus DTX is enabled to help reduce bandwidth and boost network efficiency. • Deploy Close to Exotel: Hosting your LiveKit and SIP servers near Exotel’s endpoints can really help reduce network round-trip time. If you'd like, I’m here to help you configure these settings in your LiveKit deployment or SIP trunk. Just let me know if you want to dive into any particular step or need more guidance! Sources: Bringing Zoom's end-to-end optimizations to WebRTC | Decentraland's Catalyst: using WebRTC to interact in the metaverse | Live Conversations with AI using ChatGPT and WebRTC | plugins/google/src/beta/realtime/realtime_api.ts | livekit-plugins/livekit-plugins-google/livekit/plugins/google/realtime/real...
f
@rapid-van-16677 Please help me out . I am. trying to connect my self hosted sip server with the exotel and are you able to do the outbound calling from the livekit agent
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!