Skip to main content
Version: 0.0.x

Data Channel

This guide explains how to send and receive messages (string or bytes) using the VideoSDK DataChannel.

The DataChannel supports two reliability modes:

  • RELIABLE → guaranteed delivery (ordered, slower).
  • UNRELIABLE → faster, but delivery is not guaranteed (unordered).

Sending Messages

Messages can be sent using the meeting.send(...) method. Both string and bytes payloads are supported.

# Send a string (reliable)
await meeting.send(
"Hello from Python!",
{"reliability": ReliabilityModes.RELIABLE.value}
)

# Send a string (unreliable)
await meeting.send(
"Quick update",
{"reliability": ReliabilityModes.UNRELIABLE.value}
)

# Send bytes (unreliable)
await meeting.send(
b"\x00\x01\x02\x03",
{"reliability": ReliabilityModes.UNRELIABLE.value}
)

note

Remember that while using the data channel, the message payload will be broadcast to all participants in the room by default.

Receiving Messages

To receive DataChannel messages, implement the on_data event handler in your custom event class.

It can be implemented using the MeetingEventHandler class:

def on_data(self, data):
print("Message received:")
print(f"Payload: {data['payload']}")
print(f"From: {data['from']}")
print(f"Reliability: {data['reliability']}")
print(f"Timestamp: {data['timestamp']}")

When working with DataChannel in VideoSDK, keep the following limits in mind:

  • MAX_PAYLOAD_SIZE15 * 1024 (15 KB)

    • The maximum size for a single message payload.
    • If you try to send a larger payload, it will be rejected.
  • MAX_BUFFER_SIZE65535 (≈ 64 KB)

    • The maximum buffer size available for queued messages.
    • If the buffer is full, new messages may fail until space is cleared.

Got a Question? Ask us on discord