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;
}
| Field | Rule |
|---|---|
index | Starts at 1 and increases. Responses echo it back, which is how one socket serves concurrent calls. |
service_name | Fully qualified, e.g. bale.meet.v1.Meet |
payload | Opaque bytes to the envelope; the real message once decoded |
metadata | 12 key_values, all string_value — see below |
Metadata — verified field by field
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.
| # | Key | Captured value |
|---|---|---|
| 1 | app_version | "189009" |
| 2 | browser_type | "1" |
| 3 | browser_version | "158.0.0.0" ← string |
| 4 | os_type | "3" |
| 5 | session_id | epoch milliseconds |
| 6 | language | "fa" |
| 7–12 | mt_* | 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
JoinGroupCall—{callId, name:{text}}→{groupCall:{id, room, token}, states:[]}GetWssURL—{callId}→{url:"wss://meet-gwbm5.ble.ir"}- 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
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.