What would be the reason the react sdk doesn't tri...
# ask-ai
d
What would be the reason the react sdk doesn't trigger the call to the back-end? The token and room is created but the agent doesn't join
t
Thanks for reaching out, Matiyas. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks for reaching out! There are a few common reasons why the React SDK might not trigger a backend call when the token and room are created but the agent doesn’t join. Let’s walk through some important areas to check together: • Agent Dispatch Configuration: It’s important to make sure the token generation includes the right room configuration along with the agent’s name. If you’ve set an agent name, it needs to be part of the token’s room configuration so the agent can be dispatched properly. • Room Creation vs. Agent Connection Timing: Double-check that the room is being created automatically when the participant connects with a valid token. Sometimes, explicit room creation isn’t necessary. • Backend Call Patterns: Take a look at whether the application is making the correct backend calls, like generating tokens and initiating calls. The request body should include all the necessary room configuration and agent details. • Connection Monitoring: Keep an eye on the connection state using the SDK’s events and properties, such as
room.connectionState
, to see when the connection is established or lost. • Token Content Verification: You might want to decode the JWT token to confirm it contains the expected room configuration and agent details. To help troubleshoot this further, could you please confirm a few things for me? • Are you seeing the token generation API call in your network logs? • Does the token generation request include the agent configuration? • Are you monitoring room connection events to check if the user connects? • Are you using automatic or explicit agent dispatch? • Do you notice any error messages in the browser console or network requests? With these details, we’ll be in a great position to identify what’s going on and find the best next steps. I’m here to help you through this! Sources: Web and mobile frontends | LiveKit Docs | Authentication | LiveKit Docs | hooks/useRoom.ts | ivr-nagivator/frontend/src/App.tsx | packages/livekit-server-sdk/README.md
d
The case is, the agent joins conditionally, it could be joining one time and the other time doesn't.
t
When an agent joins conditionally, there are a few common causes we can explore together to help you get to the bottom of this: • Insufficient Worker Availability: Sometimes, if there aren’t enough agent workers running, some dispatch requests might not go through. It’s a good idea to ensure you have multiple agent instances running for each
agent_name
and that load balancing is set up properly. • Job Orchestration Timeouts: If a worker doesn’t accept a job within the set timeout, the request could fail. Double-check your timeout settings and keep an eye on how jobs are being assigned. • Agent Cold Starts: Depending on your plan, agents might shut down after sessions end and need some time to restart, which can cause delays or failures when joining. • Resource Contention: Running other applications on the same server as your agent can sometimes cause resource conflicts, so it’s best to avoid that. • Process Isolation Issues: Since each job runs in its own process, any crashes or mismanagement here could lead to occasional failures. To dig a little deeper, you might want to: • Monitor the timing of agent joins and check participant states like
JOINING
,
JOINED
, and
ACTIVE
. • Look into the agent registration status and how jobs are being assigned. • Try using load testing tools to see how often agents successfully join and if there are any delays. • Review your logs for errors such as "room connection not established within 10 seconds." Could you let me know if you’re running multiple agent instances and if you’ve noticed any specific error messages or patterns in the logs? This info will really help us pinpoint what’s going on and find the best solution for you. Sources: Operational Guidance & Best Practices | livekit/livekit_composite | DeepWik... | agents/src/job.ts | test/agent_test.go | README.md | pkg/loadtester/agentloadtester.go