happy-night-10979
09/11/2025, 1:15 PMawait roomService.deleteRoom(ctx.job.room?.name);
before the session starts?
second question: before the session starts and before ctx.connect is called, can I send message via ctx.room.localParticipant.publishData()
?tall-airline-16756
09/11/2025, 1:15 PMtall-airline-16756
09/11/2025, 1:16 PMawait roomService.deleteRoom(ctx.job.room?.name);
before the session starts. This is a great way to tidy up any rooms that were set up in advance but aren’t needed anymore, even if no one has joined yet.
That said, when it comes to sending messages with ctx.room.localParticipant.publishData()
, you’ll need to wait until after ctx.connect
has been called. The connection has to be fully established first because the localParticipant
object and data channel only become ready once ctx.connect
finishes.
Sources: Inside a session | LiveKit Docs | packages/livekit-rtc/src/room.ts | livekit-rtc/livekit/rtc/participant.py | livekit-ffi/src/server/room.rshappy-night-10979
09/11/2025, 1:20 PMctx.connect
is called, I need to find another way (other than ctx.room.localParticipant.publishData()) how to let front end know about that and display error message, right?tall-airline-16756
09/11/2025, 1:21 PMctx.connect
is called, it’s important to have another way to let the frontend know and show an error message. Here are a couple of friendly approaches you can try:
• Client-Side Errors: For things like media device access issues, you can use event listeners such as RoomEvent.MediaDevicesError
or the onMediaDeviceFailure
prop in the LiveKit React components. These help you catch and display errors right away, keeping your users informed.
• Server-Side Errors: If errors happen in your business logic before ctx.connect
, wrapping your code in a try/catch
block and logging the errors on the server is a great start. Then, you can notify the frontend through API callbacks, WebSocket messages, or even some pre-checks in your frontend code to keep everything smooth.
If you’d like, I’m here to help with more details or examples on how to set any of these up—just let me know!
Sources: src/api/SignalClient.ts | External data and RAG | LiveKit Docs | External data and RAG | LiveKit Docs | complex-agents/nutrition-assistant/nutrition-assistant-frontend/app/page.ts... | components/app.tsxhappy-night-10979
09/11/2025, 1:37 PMnew RoomAgentDispatch
, for example several larger objects, is there some limit for how much data I can send through metadata?tall-airline-16756
09/11/2025, 1:38 PMmetadata
field for both rooms and participants, as well as to participant attributes (which includes the combined size of all keys and values).
If you find yourself needing to send larger data, a helpful approach would be to store that data externally—like in a database or cloud storage—and then include a reference (such as a URL or ID) in the metadata. This way, everything stays smooth and efficient!
Sources: Participant attributes and metadata | LiveKit Docs