Arash Taher

Stream ID error in Go

When connecting to another service for sending GraphQL queries (both client and server in Go), we were getting this error: stream error: stream ID 3; INTERNAL_ERROR; received from peer

Problem is that after searching, I couldn’t any good explanation on the cause of this error. In one GitHub issue thread it was even suggested to switch from WLAN to LAN to fix the problem.

The way we solved the issue in our system was by retrying failed requests with back-off time. The cause of the issue still remained unknown.

So I decided to take a deeper look into it: I checked the Go source code to see when this error is thrown. I found one occurance of stream ID in the code, which was in a test case here.

If you check the code you can see how it’s set up: Two HTTP requests are sent. The second one timed out. With that, if we’re in HTTP2 mode, we will get this error: stream ID 3; INTERNAL_ERROR

Why 3? Because stream number in HTTP specification mandates even numbers for server and odd numbers for client stream:

Streams are identified with an unsigned 31-bit integer. Streams initiated by a client MUST use odd-numbered stream identifiers; those initiated by the server MUST use even-numbered stream identifiers.

Then what the error tells us is that second client-initiated stream was failed due to some internal error on the server (in the case of the test in Go code, time out)

Solution:

Please let me know if you also faced the similar issue and how you handled it.
Hope it helps.

Tagged: #Go

Subscribe to Newsletter