Search code examples
protocolshttp2

HTTP2 expects streams to be opened following the sequence


I haven't seen this claim in the official HTTP2 spec but it seems that if you open streams with IDs that do not represent sequential numbers, the server responds with a GoAway frame having ProtocolError as a reason.

Example (INVALID):

=> HEADER{sid: 3}
=> HEADER{sid: 1}
<= GoAway{ProtoclError}

Example (VALID):

=> HEADER{sid: 1}
=> HEADER{sid: 3}
<= ... All good ...

Why is that? Can someone point me to the right section in the spec, pelase?


Solution

  • This is stated in the [HTTP/2 specification, section 5.1.1]:(https://datatracker.ietf.org/doc/html/rfc7540#section-5.1.1)

    The identifier of a newly established stream MUST be numerically greater than all streams that the initiating endpoint has opened or reserved.
    ...
    An endpoint that receives an unexpected stream identifier MUST respond with a connection error (Section 5.4.1) of type PROTOCOL_ERROR.