http2 streams and bi-directionnal stream or req/resp streams

453 views
Skip to first unread message

Benoit Chesneau

unread,
Apr 29, 2016, 3:45:17 AM4/29/16
to grp...@googlegroups.com
Hi,

What is the relation between an http2 stream and a grpc stream?

uni req seems to use 1 stream in one http2 connection but i'm not sure how is handled a bi-directional stream. Are there many req/resp in an http2 stream done or are you making multiple req/resp in the same http2 stream? What is the workflow? Knowing it would help me to build a compatible solution in erlang possibly :)

- benoît

Nathan Mittler

unread,
Apr 29, 2016, 9:45:29 AM4/29/16
to Benoit Chesneau, grp...@googlegroups.com
Hi Benoit,
A grpc stream is an abstraction over a single HTTP/2 stream. Each message sent over a grpc stream will result in an HTTP/2 DATA frame on the wire (for the same HTTP/2 stream).  You can see more details in the grpc-over-http2 spec.

--
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 post to this group, send email to grp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CAJNb-9qw7KfJTTBsQBqoubv2gn1_hsR1NSuvHTiSTRu%3DkWQ89Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Benoit Chesneau

unread,
Apr 29, 2016, 11:32:30 AM4/29/16
to Nathan Mittler, grp...@googlegroups.com
Hi Nathan,

I read the doc but the thing i don't understand is how you can send and receive messages at the same time. or does thr client send all the messages before getting the responses from the server?

Nathan Mittler

unread,
Apr 29, 2016, 11:53:18 AM4/29/16
to Benoit Chesneau, grp...@googlegroups.com
Are you asking how streaming works at the HTTP/2 level or how to use grpc API? The latter would depend on which language you're using.

Benoit Chesneau

unread,
Apr 29, 2016, 12:02:52 PM4/29/16
to Nathan Mittler, grp...@googlegroups.com
on the grpc level. i am not sure what bi directionnal stream means at that level. is this only that you send a stream request then a stream response. i was thinking (surely badly) that you could have some kind of ping pong in the same http2 stream reading the doc. Does the doc describe a cycleof req/resp?

Nathan Mittler

unread,
Apr 29, 2016, 12:17:15 PM4/29/16
to Benoit Chesneau, grp...@googlegroups.com
Bidi streams are denoted at the service-level by adding the "stream" keyword to both the request and response (see example: https://github.com/grpc/grpc/blob/master/examples/protos/route_guide.proto#L67). In grpc, all streams are initiated by the client.  Once the grpc/http2 stream is established, both endpoints are free to send messages at will.

Eric Anderson

unread,
Apr 29, 2016, 1:03:25 PM4/29/16
to Benoit Chesneau, Nathan Mittler, grp...@googlegroups.com
On Fri, Apr 29, 2016 at 9:02 AM, Benoit Chesneau <bche...@gmail.com> wrote:
on the grpc level. i am not sure what bi directionnal stream means at that level. is this only that you send a stream request then a stream response. i was thinking (surely badly) that you could have some kind of ping pong in the same http2 stream reading the doc. Does the doc describe a cycleof req/resp?

The HTTP/1 spec[1] permits full bi-di communication on a request; the response can be produced before the request is complete. However, many HTTP/1 implementations don't support this.

With HTTP/2 it is easier for implementations to support bi-di streaming than to force strict request/response. We are relying on this behavior, and there is a growing consensus in the HTTP community (for example browsers) that this should be supported and there is some hope it can kill WebSocket.

1. With HTTP 1.0 it is possible, but 1.1 with chunking improves error handling
Reply all
Reply to author
Forward
0 new messages