Does every data frame contains exactly one grpc message?

63 views
Skip to first unread message

Harie Amjari

unread,
Jan 21, 2024, 6:28:20 PMJan 21
to grpc.io
Hi!, I read the grpc spec from the github but one thing isn't clear for me:

> The repeated sequence of Length-Prefixed-Message items is delivered in DATA frames

Does this mean that in a streaming gRPC, a data frame must contain exactly one grpc message? Is this enforced?

Michael Lumish

unread,
Jan 22, 2024, 12:29:30 PMJan 22
to Harie Amjari, grpc.io
No. In a stream, the contents of all of the DATA frames sent in one direction are collectively treated as a byte stream that contains length-delimited gRPC messages, independent of the DATA frame boundaries. In other words, any single DATA frame can contain only part of a message, or multiple messages, or a combination of those.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/237bf62d-180b-4b99-9d73-a2382f163f2dn%40googlegroups.com.

Harie Amjari

unread,
Jan 22, 2024, 4:58:26 PMJan 22
to grpc.io
Ok got it.

I was thinking that in a bidirecttional streaming RPC, the server can start sending out replies even before an END STREAM is received (from the DATA frame header). So it's like, (1) the server parses one grpc length prefixed message, (2) call user defined functions, (3) sends it [one grpc message] immediately in a DATA frame without waiting for other messages (and even before an END STREAM).

Thanks. That answered my question.

Michael Lumish

unread,
Jan 22, 2024, 5:55:57 PMJan 22
to Harie Amjari, grpc.io
Yes, it is common in bidirectional streaming RPCs for the server to send messages before the client ends its side of the stream. For example, the server could respond to each message the client sends with a message, indefinitely, without the stream ever intentionally closing.

Reply all
Reply to author
Forward
0 new messages