gRPC client
This page is a practical guide for building a gRPC streaming client.
Minimal flow
Conceptually, you:
- create a channel to the gRPC endpoint
- pass the token in metadata
- open a bidirectional stream (or the specific streaming method used by your API)
- send subscribe/publish messages over that stream
Pseudo-code:
token = "AT_..."
client = grpc_connect("https://api.example.com:443", metadata={authorization: "Bearer " + token})
stream = client.open_stream()
stream.send(subscribe(tenant="prod", channel="orders.#"))
for msg in stream.recv_loop():
handle(msg)
See gRPC API for the exact service and message shapes.
Reconnect strategy (recommended)
Treat gRPC streams similarly to WebSocket connections:
- reconnect on error,
- re-send subscriptions after reconnect,
- expect a propagation delay after resubscribe (join window).
See Delivery semantics.
Common pitfalls
- Metadata missing: token is not passed correctly -> “invalid token”.
- Keepalive / timeouts: defaults may close idle streams; tune if needed.
- Slow consumer: if receive loop blocks, you may be disconnected.
See also: