big-microphone-99982
07/22/2025, 7:53 AMtall-airline-16756
07/22/2025, 7:53 AMtall-airline-16756
07/22/2025, 7:54 AMctx.connect() to detect if a user participant does not join within a certain period by combining ctx.wait_for_participant() with a timeout mechanism.
For example, in Python using LiveKit Agents, you can use asyncio.wait_for() to wrap `ctx.wait_for_participant()`:
async def entrypoint(ctx: JobContext):
await ctx.connect(auto_subscribe=agents.AutoSubscribe.AUDIO_ONLY)
try:
await asyncio.wait_for(ctx.wait_for_participant(), timeout=30.0)
<http://logger.info|logger.info>("Participant connected successfully")
except asyncio.TimeoutError:
logger.warning("No participant joined within 30 seconds")
await ctx.room.disconnect()
return
This approach will raise a TimeoutError if no participant joins within the specified period (e.g., 30 seconds), allowing you to handle the timeout as needed.
The same pattern can be applied in Node.js using Promise.race() with the equivalent waitForParticipant() method.
Sources: examples/rpc.py | examples/rpc/index.ts | complex-agents/ivr-agent/agent.py | JobContext | LiveKit Agents