0

In the http2-spec, the scenario where the server half-closed the stream (server sent http2.END_STREAM), the client is still allowed to send data (since it's half-closed).

Consider the following gRPC scenario:

  • Client opens bidi-stream to server and starts sending data
  • Server closes the response stream and sends the status trailers (translates to sending http2.END_STREAM)
  • Client continues to send data

Are the semantics well-defined in gRPC?

Possible ways:

  • Follow the http2-spec: The client is allowed to continue to send data that is processed by the server.
  • Not follow the http2-spec: The client-connection is implicitly terminated if the server closes the stream.

NOTE: I just tested and it looks like gRPC for Java follows variant "not follow the http2-spec", i.e. if the server closes the downwards stream, also the upwards stream is closed.

user3612643
  • 5,096
  • 7
  • 34
  • 55

1 Answers1

2

In the semantics of gRPC, when the server sends a status, it means that the entire call is complete. The official servers implementations send RST_STREAM in addition to END_STREAM to shut down the stream in both directions at the HTTP/2 protocol level, in accordance with this part of Section 8.1 of the HTTP/2 RFC:

A server can send a complete response prior to the client sending an entire request if the response does not depend on any portion of the request that has not been sent and received. When this is true, a server MAY request that the client abort transmission of a request without error by sending a RST_STREAM with an error code of NO_ERROR after sending a complete response (i.e., a frame with the END_STREAM flag).

When servers do not do this, the gRPC protocol does not prohibit the client sending more data after receiving a status but the server will not process it so there is no reason to do so. Because of this, when the official gRPC clients receive a status they consider the call to be complete and stop sending data.

murgatroid99
  • 19,007
  • 10
  • 60
  • 95
  • The HTTP/2 spec mentions the case. See the last paragraph of https://httpwg.org/specs/rfc7540.html#rfc.section.8.1 . gRPC is opting to send the `RST_STREAM(NO_ERROR)` as permitted by that paragraph. – Eric Anderson Apr 04 '19 at 19:16