English فارسی

Wire protocol

What actually goes over the socket. This is the page to read if you are debugging a frame, or writing a client in another language.

Topology

RPC (protobuf over WebSocket)          Media (WebRTC)
wss://next-ws.bale.ai/ws/              wss://meet-<node>.ble.ir/rtc/v1
        │                                       │
        ├── handshake: access_token + headers   ├── access_token (LiveKit JWT)
        ├── request{index, service, method}     ├── join_request (SDP blob)
        └── response/update{index}              └── ICE, opus 48 kHz

Two independent connections. The RPC socket manages membership and state; the RTC socket carries audio.

WebSocket handshake

GET /ws/ HTTP/1.1
Host: next-ws.bale.ai
Origin: https://web.bale.ai
Upgrade: websocket
Sec-WebSocket-Key: …
Sec-WebSocket-Protocol: next-ws
access-token: <jwt>

The token is the same JWT used for gRPC-web. A rejected token closes with code 4401 — that is the fastest way to tell "bad session" from "server down".

Envelope

Every frame is a request.Request or a response.Response oneof:

message Request {
  oneof body {
    WsRequest  ws_request;
    WsResponse ws_response;
    WsUpdate   ws_update;
    …
  }
}

message WsRequest {
  int32  index       = 1;   // client-chosen, strictly increasing
  string service_name= 2;
  string method      = 3;
  bytes  payload     = 4;   // the actual protobuf message
  Metadata metadata  = 5;
}
FieldRule
indexStarts at 1 and increases. Responses echo it back, which is how one socket serves concurrent calls.
service_nameFully qualified, e.g. bale.meet.v1.Meet
payloadOpaque bytes to the envelope; the real message once decoded
metadata12 key_values, all string_value — see below

Metadata — verified field by field

Two mistakes here break the connection.

browser_version is a string ("158.0.0.0"), not a fixed64. And the six mt_* keys plus language are required by the current build. Earlier versions of this library sent an integer version and omitted those keys; the handshake still opened but the server behaved differently.

#KeyCaptured value
1app_version"189009"
2browser_type"1"
3browser_version"158.0.0.0" ← string
4os_type"3"
5session_idepoch milliseconds
6language"fa"
7–12mt_*device/browser markers

Key order is preserved. tests/test_meet_capture.py asserts equality against the captured bytes.

A real frame

Creating a meeting link with {"isPublic": true}:

index        = 22
service_name = "bale.meet.v1.Meet"
method       = "GenerateCallLink"
payload      = 08 01            ← field 1 (bool) = true
# Reproduce it exactly
dynamic.encode("bale.meet.v1.Meet", "GenerateCallLink", {"isPublic": True}).hex()
# '0801'

The join sequence, from the capture

  1. JoinGroupCall — {callId, name:{text}} → {groupCall:{id, room, token}, states:[]}
  2. GetWssURL — {callId} → {url:"wss://meet-gwbm5.ble.ir"}
  3. WebRTC connect — LiveKit JWT claims:
{
  "sub": "256049633",
  "name": "xyz",
  "iss": "APIVLFKgSeHLgRb",
  "metadata": "{\"user_id\":256049633,\"name\":\"xyz\"}",
  "video": {
    "room": "375ddee9-ee36-4b0b-b313-1abbb71bc48c",
    "roomJoin": true,
    "canPublish": true,
    "canSubscribe": true
  }
}

int64 and the nineteen-digit id

Call ids are signed 64-bit integers.

3989589941225409291 fits in int64 but not in int32 or in a JS number without care. On the wire it is a varint. GenerateCallLink takes it as a bare field; SetLinkTitle wraps it as {value: …}. Both are handled, and both are tested.

gRPC-web

Used before the socket is open: StartPhoneAuth, ValidateCode, uploads. Request framing is standard gRPC-web — a 5-byte prefix (compression flag + 4-byte big-endian length) then the message.

Content-Type: application/grpc-web+proto
x-grpc-web: 1
x-user-agent: grpc-web-javascript/0.1

The response is a length-prefixed body followed by a trailers frame carrying grpc-status.

bale xyz 1.0.0 · MIT licensed · unofficial client © 2026 bale xyz contributors