Skip to main content

Unidirectional GRPC

It's possible to connect to GRPC unidirectional stream to consume real-time messages from Centrifugo. In this case you need to generate GRPC code for your language on client-side.

Protobuf definitions can be found here.

tip

We publish Centrifugo GRPC uni stream Protobuf definitions to Buf Schema Registry. This means that it's possible to depend on pre-generated Protobuf definitions for your programming language instead of manually generating them from the schema file (see SDKs supported by Buf registry here).

The main label follows the latest stable Centrifugo release. Starting from Centrifugo v6.10.0, every release is also published under its version label, for example buf.build/centrifugo/unistream:v6.10.0.

How to enable​

{
"uni_grpc": {
"enabled": true
}
}

Default endpoint​

Centrifugo runs uni GRPC server on port 11000 (by default).

Supported data formats​

JSON and binary.

uni_grpc​

uni_grpc.enabled​

Boolean, default: false.

Enables unidirectional GRPC endpoint.

config.json
{
...
"uni_grpc": {
"enabled": true
}
}

uni_grpc.port​

Integer, default 11000.

Port to listen on.

uni_grpc.address​

String, default "" (listen on all interfaces)

Address to bind uni GRPC to.

uni_grpc.max_receive_message_size​

Default: 65536 (64KB)

Maximum allowed size of a first connect message received from GRPC connection in bytes.

uni_grpc.tls​

TLSConfig.

Allows configuring TLS for unidirectional GRPC server.

Example​

We have example for Go language. In general, the algorithm is like this:

  1. Copy Protobuf definitions
  2. Generate GRPC client code
  3. Use generated code to connect to Centrifugo
  4. Process Push messages, drop unknown Pushes, handle those necessary for the application.