While load testing, I am getting this error - ```d...
# ask-ai
b
While load testing, I am getting this error -
Copy code
dropping candidate with ufrag urNBOJdDOrOKAJet because it doesn't match the current ufrags
I am executing this command to load test the agent -
Copy code
lk perf agent-load-test --rooms 5 --agent-name calling_agent --echo-speech-delay 10s --duration 3m
This is my agent code - calling_agent.py
Copy code
import logging
import os
from pathlib import Path
from dotenv import load_dotenv
from livekit.agents import JobContext, WorkerOptions, cli
from livekit.agents.voice import Agent, AgentSession
from livekit.plugins import openai, silero, deepgram, google, elevenlabs
from livekit.plugins.turn_detector.english import EnglishModel


load_dotenv(dotenv_path=Path(__file__).parent.parent.parent / '.env')

logger = logging.getLogger("calling-agent")
logger.setLevel(<http://logging.INFO|logging.INFO>)

class SimpleAgent(Agent):
    def __init__(self) -> None:
        super().__init__(
            instructions="""
                You are calling someone on the phone. Your goal is to know if they prefer 
                chocolate or vanilla ice cream. That's the only question you should ask, and 
                you should get right to the point. Say something like "Hello, I'm calling to 
                ask you a question about ice cream. Do you prefer chocolate or vanilla?"
            """,
            stt=deepgram.STT(),
            llm=google.LLM(vertexai=True,location="us-west4"),
            tts=elevenlabs.TTS(),
            vad=silero.VAD.load(),
            turn_detection=EnglishModel()
        )

    async def on_enter(self):
        self.session.generate_reply()


async def entrypoint(ctx: JobContext):
    session = AgentSession()

    await session.start(
        agent=SimpleAgent(),
        room=ctx.room
    )


if __name__ == "__main__":
    cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))
make_call.py
Copy code
import asyncio
import os
import logging
from pathlib import Path
from dotenv import load_dotenv
from livekit import api

# Load environment variables
load_dotenv(dotenv_path=Path(__file__).parent.parent.parent / '.env')

# Set up logging
logger = logging.getLogger("make-call")
logger.setLevel(<http://logging.INFO|logging.INFO>)
# Configuration
room_name = "my-room"
agent_name = "test-agent"
outbound_trunk_id = ""


async def make_call(phone_number):
    """Create a dispatch and add a SIP participant to call the phone number"""
    lkapi = api.LiveKitAPI()

    # Create agent dispatch
    <http://logger.info|logger.info>(f"Creating dispatch for agent {agent_name} in room {room_name}")
    dispatch = await lkapi.agent_dispatch.create_dispatch(
        api.CreateAgentDispatchRequest(
            agent_name=agent_name, room=room_name, metadata=phone_number
        )
    )
    <http://logger.info|logger.info>(f"Created dispatch: {dispatch}")

    # Create SIP participant to make the call
    if not outbound_trunk_id or not outbound_trunk_id.startswith("ST_"):
        logger.error("SIP_OUTBOUND_TRUNK_ID is not set or invalid")
        return

    <http://logger.info|logger.info>(f"Dialing {phone_number} to room {room_name}")

    try:
        # Create SIP participant to initiate the call
        sip_participant = await lkapi.sip.create_sip_participant(
            api.CreateSIPParticipantRequest(
                room_name=room_name,
                sip_trunk_id=outbound_trunk_id,
                sip_call_to=phone_number,
                participant_identity="phone_user",
            )
        )
        <http://logger.info|logger.info>(f"Created SIP participant: {sip_participant}")
    except Exception as e:
        logger.error(f"Error creating SIP participant: {e}")

    # Close API connection
    await lkapi.aclose()


async def main():
    # Replace with the actual phone number including country code
    phone_number = "+1342776123"
    await make_call(phone_number)


if __name__ == "__main__":
    asyncio.run(main())
t
Thanks for reaching out, Harsh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! That error
dropping candidate with ufrag because it doesn't match the current ufrags
usually pops up when the username fragments (ufrags) for ICE candidates don’t line up. This often happens during the ICE candidate trickling process when the ufrag in the SDP fragment isn’t quite the same as the one in your current session or offer. Here’s how you can fix it: • Make sure the ufrag and pwd values stay consistent across all your SDP messages — that means the offer, the answer, and any ICE candidates sent later through trickling. • Double-check that your SDP fragments belong to the right session and that the ufrags match your current ICE setup. If you’re working with LiveKit’s SDP handling, just confirm that the ufrag values in the fragments match those in your initial SDP offer or answer. And hey, if you want me to walk you through it or have any other questions, just let me know — I’m happy to help!
b
I am not doing any SDP handling in my code. What changes should I do in my code to handle this issue?
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!