Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

gRPC client

This page is a practical guide for building a gRPC streaming client.

Minimal flow

Conceptually, you:

  1. create a channel to the gRPC endpoint
  2. pass the token in metadata
  3. open a bidirectional stream (or the specific streaming method used by your API)
  4. 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.

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:

gRPC client