rapid-judge-7554
11/09/2025, 6:51 PMlkapi = api.LiveKitAPI()
data_payload = {
"type": "perception_result",
"analysis": analysis.model_dump(),
}
json_data = json.dumps(data_payload).encode("utf-8")
await lkapi.room.send_data(
send=api.SendDataRequest(
room=task_context.room_name,
data=json_data,
kind="LOSSY",
)
)
Then in the livekit room, i have it this way
ctx.room.on("data_received", on_data_received) # i logged the result of the callback
but funny thing is, i dont see the log in the livekit room with payload, but i see the log from other services eg. tavus, what could be the problem? ive ensured that im sending it to the right roomtall-airline-16756
11/09/2025, 6:51 PMtall-airline-16756
11/09/2025, 6:52 PMsend_data method is correctly targeting the right room name and using the right delivery mode, like "LOSSY".
• Make sure the on_data_received event handler is properly set up in the room and is actively listening for any incoming data.
• Take a moment to verify that the data payload is formatted and encoded correctly before it’s sent to the room.
• Also, confirm that both the Redis worker and the LiveKit room are connected and running smoothly when you’re sending the data.
• It might help to test the send_data functionality using the LiveKit CLI. This can help us see if the issue is with the worker or the room setup.
If you try these steps and things still aren't working, please don’t hesitate to share more details like the room name, worker logs, or any error messages you’re seeing. I’m here to help you through this!
Sources: internal/bus/bus_redis.go | agent-console/app/api/room/send-data/route.ts | cmd/lk/room.go | Agent Testing & CI/CD | livekit/livekit_composite | DeepWiki | livekit-ffi/src/server/room.rsrapid-judge-7554
11/09/2025, 7:15 PMroom event dataReceived
{
"room": "oculsus_5580f7",
"roomID": "RM_SGgXtPiDhCYN",
"participant": "user-oculus",
"pID": "PA_WLqYbkmRfrg7",
"event": "dataReceived",
"args": [
"lk-chat-topic"
]
}
but here's confusing me, i can see other services "data_received" room callbacks in the server logs but not the one from the queue
ive even i changed the kind to RELIABLE
and changed the destination entities
await lkapi.room.send_data(
send=api.SendDataRequest(
room=task_context.room_name,
data=json.dumps(analysis_dict).encode("utf-8"),
kind="RELIABLE",
destination_identities=[task_context.agent_identity, task_context.user_identity],
)
)tall-airline-16756
11/09/2025, 7:16 PMdata_received event is something that happens on the client side when a participant gets a data packet through the LiveKit SDKs. It’s not automatically logged by the LiveKit server, which is why you might notice it on the frontend but not see it in the server logs.
To help you check the data flow on the server side, here are a few friendly tips:
• You can turn on debug logging in the LiveKit server settings to get a closer look at how messages are routed internally.
• Keep an eye on Redis channels directly to make sure data packets are being sent and routed as expected.
• Try logging the payload structure in your Redis worker to confirm everything looks right.
If you’d like, I’m here to help you step-by-step with enabling debug logs or checking the Redis message flow. Just let me know!
Sources: livekit-rtc/livekit/rtc/room.py | config-sample.yaml | Data packets | LiveKit docs | agent-console/lib/event-definitions.tsx | lib/src/events.dartrapid-judge-7554
11/09/2025, 7:38 PMlkapi.room.send_data and also the callbacktall-airline-16756
11/09/2025, 7:39 PMlkapi.room.send_data for sending data to a LiveKit room and managing the data_received callback:
Sending Data
await lkapi.room.send_data(
send=api.SendDataRequest(
room="room_name",
data=json.dumps({"key": "value"}).encode("utf-8"),
kind="RELIABLE", # or "LOSSY"
destination_identities=["participant1", "participant2"] # Optional
)
)
This will send a JSON payload to the room you specify. You have the option to pick RELIABLE for guaranteed delivery, or LOSSY if you prefer faster transmission without a delivery guarantee.
Handling the Callback
On the client side, you can easily listen for the data_received event like this:
@room.on("data_received")
def on_data_received(data):
print(f"Received data: {data}")
This way, you’ll see the received data logged whenever a packet arrives in the room.
If you have any questions or would like me to walk you through more examples, just let me know—I’m here to help!
Sources: Data packets | LiveKit docs | src/test/kotlin/io/livekit/server/RoomServiceClientTest.kt | cmd/lk/room.go | callback_test.go