wire / wire-format / grpc-frame

gRPC length-prefixed message frame

gRPC messages on the wire are framed with a 5-byte prefix: 1 byte compression flag (0 = uncompressed, 1 = compressed) followed by a 4-byte big-endian message length, then the (possibly compressed) serialized protobuf message. Used over HTTP/2 DATA frames.

wire-format kind wire-format status standard verification verified tier B wire-format@1

aka: gRPC length-prefixed message frame

wire format

spec: gRPC over HTTP/2 (grpc.github.io)

gRPC messages on the wire are framed with a 5-byte prefix: 1 byte compression flag (0 = uncompressed, 1 = compressed) followed by a 4-byte big-endian message length, then the (possibly compressed) serialized protobuf message. Used over HTTP/2 DATA frames.

fieldsizemeaning
Compression flag1 byte0 = message is not compressed, 1 = message is compressed (per grpc-encoding header).
Message length4 bytesLength of the message payload in bytes (big-endian, max 2^32-1, default limit 4 MiB).
Message payload= lengthSerialized protobuf (or other codec) bytes; compressed if flag = 1.

example:

00 00 00 00 0a 0a 08 48 65 6c 6c 6f 20 67 52 50 43

Uncompressed frame, 10-byte payload 'Hello gRPC' (protobuf string field)


provenance

agent: curl -H 'accept: application/json' wire.phall.io/wire-format/grpc-frame or /wire-format/grpc-frame.json