After upgrading `livekit` (python-sdks) from 1.0.1...
# ask-ai
b
After upgrading
livekit
(python-sdks) from 1.0.13 to 1.0.16, the room's
data_received
event handler is not triggered for data send via the Server API. Tested and reproduced the issue using the basic_room.py example. The event handler is triggered for the data sent via python-sdk (
room.local_participant.publish_data()
). What is causing this issue? Was there any change to required parameters?
t
Thanks for reaching out, Masayuki. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks for reaching out! The
data_received
event handler in the LiveKit Python SDK is specifically designed to handle data packets sent by participants over WebRTC using
send_data()
. I understand it can be a bit confusing, but data sent via the Server API doesn’t go through the WebRTC data channel, so it won’t trigger the
data_received
event. Here are a few friendly suggestions to help you along: • Try using webhooks to capture server-side events and data—this is the best way to handle data sent via the Server API. • If you want to trigger the
data_received
event, you might want to explore the Agent SDK, which lets you create a server-side participant that sends data over WebRTC. • For more structured communication, text streams or byte streams could be great options to consider. Please don’t hesitate to reach out if you’d like any help implementing these solutions—I’m here to support you every step of the way! Sources: Webhooks | LiveKit Docs | livekit-protocol/livekit/protocol/models.py | Server-Side SDKs & Authentication | livekit/livekit_composite | DeepWiki | Sending text | LiveKit Docs | Sending files & bytes | LiveKit Docs
b
Curious when/how are we supposed to use SendData Server API if the data doesn't get delivered to agents?
t
I'm glad you asked about the
SendData
Server API! It's a powerful tool designed to send individual packets of data to one or more participants within a room. It gives you advanced control over how your data is delivered, including options for reliable or lossy transmission, and lets you target specific participants using their SIDs or identities. That said, this API is a bit low-level and works best when you need precise control over data behavior. For example, it’s great for: • Sending in-room chat messages where reliable delivery is important • Broadcasting real-time updates when speed is key • Targeting specific participants with custom data For most other situations, though, LiveKit suggests using higher-level APIs like text streams, byte streams, or RPC. These options make development smoother and handle many common scenarios more efficiently. If you’d like, I’m here to help guide you through implementing any of these approaches—just let me know! Sources: livekit/livekit_room.pb.go | packages/livekit-server-sdk/src/RoomServiceClient.ts | livekit-protocol/src/livekit.rs | Data packets | LiveKit Docs