Self Hosted SIP Latency Issue

Hello :waving_hand:

I was working on Livekit telephony directly connected to IMS through my SIP url. I’ve deployed all Livekit services [ Server, SIP, Agent ] on prem. Also created the inbound trunk as well as the dispatch rule. I’ve also a short-code allocated just for this.
I’ve used Google Realtime model and separate STT, LLM, TTS models as well but I’m experiencing a delay (>30s) on the generation of the audio from my Agent. The IMS has a configuration to timeout in 30s of inactivity But my Agent has supposed to be generating the audio before that.
I had 3 successful calls so far, which the agent responded between 7 - 10s after the call get’s picked up. I’ve added many logs to exactly track in which stage it’s failing but even though the call is ended after 30s of inactivity I see the agent logs generating the audio after 10-20 sec after the call has ended.

What could be the issue and how do I resolve this? I’ve asked on ask-ai channel but couldn’t figured it out.

Yes, I was experiencing the same issue with the SIP trunk.

Bro, let me save you the trouble. In my case, it was all the firewall problem. The RTP ports were not configured as they were expected.

I am receiving RTP on both sides and the required ports are open, but I am still experiencing the same issue.

That’s Weird. Maybe use the livekit events for more debugging logs and try to see at which stage it’s delaying.