Repository navigation
Description
If you are reporting any crash or any potential security issue, do not
open an issue in this repo. Please report the issue via emailing
[email protected] where the issue will be triaged appropriately.
Title: gRPC server issues with envoy proxy on RST_STREAM
Description:
We experienced client unary requests (NodeJS clients) randomly fails while fetching data from a Golang gRPC server. Both use Istio(envoy proxies). Issues are randomly happening typically around 1-10%.
We noted that issues are popping up easily if the requests are concurrently and the amount of data fetched is not limited.
At first we thought that the issue was caused due to the following issue: #30149
But after we enabled the runtime option on both side and tested it, it did not help to mitigate the issues.
A similar issue was reported here: grpc/grpc-go#7623
Client errors:
Errors are only reported at the client side. We used 2 libraries for the testing:
A) grpc-js library:
Error: 13 INTERNAL: Received RST_STREAM with code 0 (Call ended without gRPC status)
at callErrorFromStatus (/usr/src/app/node_modules/@grpc/grpc-js/build/src/call.js:31:19)
at Object.onReceiveStatus (/usr/src/app/node_modules/@grpc/grpc-js/build/src/client.js:193:76)
B) connectrpc library:
connecterror: [invalid_argument] protocol error: missing output message for unary method
or
connecterror: [internal] protocol error: missing status
at validateTrailer (/usr/src/app/node_modules/@connectrpc/connect/dist/cjs/protocol-grpc/validate-trailer.js:42:15)
at next (/usr/src/app/node_modules/@connectrpc/connect/dist/cjs/protocol-grpc/transport.js:114:63)
or
ConnectError: [invalid_argument] protocol error: promised 11117 bytes in enveloped message, got 9920 bytes
at /usr/src/app/node_modules/@connectrpc/connect/dist/cjs/protocol/async-iterable.js:633:23
at Generator.next ()
Envoy:
No errors were reported either on the envoy client side nor in the envoy server side.
Server errors:
No errors were reported.
Example of test:
Concurrency Level: 50
Complete requests: 500
Failed requests: 41
Typically 1 request contain a payload of 250 KB and it is served in 1 ms.
We thought the issue was on the client side:
@grpc/grpc-jsthrow 'Received RST_STREAM with code 0' with retry enabled grpc/grpc-node#2569 (comment)@grpc/grpc-jsthrow 'Received RST_STREAM with code 0' with retry enabled grpc/grpc-node#2569 (comment)
But it was confirmed that the issue is likely on envoy or server side due to missing the trailers.
With Istio(envoy) we see issues.
Without Istio(envoy) we do not see the issue.
With Istio(envoy) but limiting the amount of data fetched it seems we do not experience the issues.
Envoy on the server side pointed to upstream issues:
Response flags by GRPC code:
Code Flags % Req
0 - 18.3
0 UR. 77.8 (UR - Upstream Remote reset in addition to 503 response code)
2 DR. 3.9 (DR - DownstreamRemoteReset - The response details are http2.remote_reset or http2.remote_refuse.)
Envoy logs for a failed request:
time,caller,ConnectionId,scope,thread,StreamId,Message
10:58:22.005321Z, external/envoy/source/common/http/http2/codec_impl.cc:1933, 57, envoy http2, 23,"Http2Visitor invoking stream close listener for 5141"
10:58:22.005319Z, external/envoy/source/common/http/http2/codec_impl.cc:1507, 57, envoy http2, 23,"Recouping 0 bytes of flow control window for stream 5141."
10:58:22.005316Z, external/envoy/source/common/event/dispatcher_impl.cc:233,envoy main, 23,"item added to deferred deletion list (size=6)"
10:58:22.005313Z, external/envoy/source/common/http/http2/codec_impl.cc:1444, 57, envoy http2, 23,"stream 5141 closed: 0"
10:58:22.005310Z, external/envoy/source/common/http/http2/codec_impl.cc:1248, 57, envoy http2, 23,"remote reset: 5141 0"
10:58:22.005307Z, external/envoy/source/common/http/http2/codec_impl.cc:1243, 57, envoy http2, 23,"recv frame type=RST_STREAM stream_id=5141"
10:58:22.005304Z, external/envoy/source/common/http/http2/codec_impl.cc:1397, 57, envoy http2, 23,"track inbound frame type=3 flags=0 length=4 padding_length=0"
10:58:22.005301Z, external/envoy/source/common/http/http2/codec_impl.cc:1115, 57, envoy http2, 23,"about to recv frame type=3, flags=0, stream_id=5141"
10:58:22.005298Z, external/envoy/source/common/http/http2/codec_impl.cc:1806, 57, envoy http2, 23,"Http2Visitor::OnFrameHeader(5141, 4, 3, 0)"
10:58:22.005294Z, external/envoy/source/common/http/http2/codec_impl.cc:1911, 57, envoy http2, 23,"Http2Visitor::OnEndStream(5141)"
10:58:22.005281Z, external/envoy/source/common/event/dispatcher_impl.cc:233,envoy main, 23,"item added to deferred deletion list (size=5)"
10:58:22.005253Z, external/envoy/source/common/event/scaled_range_timer_manager_impl.cc:60,envoy misc, 23,"enableTimer called on 0xXXXXXXX for 3600000ms, min is 3600000ms"
10:58:22.005235Z, external/envoy/source/common/event/dispatcher_impl.cc:233,envoy main, 23,"item added to deferred deletion list (size=4)"
10:58:22.005030Z, external/envoy/source/extensions/filters/common/lua/lua.h:210,envoy lua, 23,"marking dead N5Envoy10Extensions11HttpFilters3Lua19StreamHandleWrapperE "
10:58:22.005025Z, external/envoy/source/extensions/filters/common/lua/lua.h:219,envoy lua, 23,"marking live N5Envoy10Extensions11HttpFilters3Lua19StreamHandleWrapperE "
10:58:22.004978Z, external/envoy/source/common/event/dispatcher_impl.cc:233,envoy main, 23,"item added to deferred deletion list (size=3)"
10:58:22.004970Z, external/envoy/source/common/event/dispatcher_impl.cc:233,envoy main, 23,"item added to deferred deletion list (size=2)"
10:58:22.004952Z, external/envoy/source/common/conn_pool/conn_pool_base.cc:215, 57, envoy pool, 23,"destroying stream: 0 remaining"
10:58:22.004939Z, external/envoy/source/common/event/dispatcher_impl.cc:233,envoy main, 23,"item added to deferred deletion list (size=1)"
10:58:22.004930Z, external/envoy/source/common/http/codec_client.cc:159, 57, envoy client, 23,"request reset"
10:58:22.004899Z, external/envoy/source/common/http/codec_client.cc:137, 57, envoy client, 23,"waiting for encode to complete"
10:58:22.004894Z, external/envoy/source/common/http/codec_client.cc:129, 57, envoy client, 23,"response complete"
10:58:22.004889Z, external/envoy/source/common/http/http2/codec_impl.cc:1850, 57, envoy http2, 23,"Http2Visitor::OnEndHeadersForStream(5141)"
10:58:22.004878Z, external/envoy/source/common/http/http2/codec_impl.cc:1397, 57, envoy http2, 23,"track inbound frame type=1 flags=5 length=2 padding_length=0"
10:58:22.004876Z, external/envoy/source/common/http/http2/codec_impl.cc:1115, 57, envoy http2, 23,"about to recv frame type=1, flags=5, stream_id=5141"
10:58:22.004873Z, external/envoy/source/common/http/http2/codec_impl.cc:1806, 57, envoy http2, 23,"Http2Visitor::OnFrameHeader(5141, 2, 1, 5)"
10:58:22.004853Z, external/envoy/source/extensions/filters/common/lua/lua.h:210,envoy lua, 23,"marking dead N5Envoy10Extensions11HttpFilters3Lua19StreamHandleWrapperE "
10:58:22.004850Z, external/envoy/source/extensions/filters/common/lua/lua.h:219,envoy lua, 23,"marking live N5Envoy10Extensions11HttpFilters3Lua19StreamHandleWrapperE "
10:58:22.004807Z, external/envoy/source/common/http/http2/codec_impl.cc:1397, 57, envoy http2, 23,"track inbound frame type=0 flags=0 length=12459 padding_length=0"
10:58:22.004803Z, external/envoy/source/common/http/http2/codec_impl.cc:1167, 57, envoy http2, 23,"recv frame type=DATA stream_id=5141"
10:58:22.004800Z, external/envoy/source/common/http/http2/codec_impl.cc:1899, 57, envoy http2, 23,"Http2Visitor dispatching DATA for stream 5141"
10:58:22.004792Z, external/envoy/source/common/http/http2/codec_impl.cc:1870, 57, envoy http2, 23,"Http2Visitor: remaining data payload: 12459, end_stream: false"
10:58:22.004789Z, external/envoy/source/common/http/http2/codec_impl.cc:1858, 57, envoy http2, 23,"Http2Visitor::OnBeginDataForStream(5141, 12459)"
10:58:22.004785Z, external/envoy/source/common/http/http2/codec_impl.cc:1115, 57, envoy http2, 23,"about to recv frame type=0, flags=0, stream_id=5141"
10:58:22.004776Z, external/envoy/source/common/http/http2/codec_impl.cc:1806, 57, envoy http2, 23,"Http2Visitor::OnFrameHeader(5141, 12459, 0, 0)"
10:58:22.004656Z, external/envoy/source/extensions/filters/common/lua/lua.h:210,envoy lua, 23,"marking dead N5Envoy10Extensions11HttpFilters3Lua16HeaderMapWrapperE
10:58:22.004653Z, external/envoy/source/extensions/filters/common/lua/lua.h:210,envoy lua, 23,"marking dead N5Envoy10Extensions11HttpFilters3Lua19StreamHandleWrapperE
10:58:22.004649Z, external/envoy/source/extensions/filters/common/lua/lua.cc:39,envoy lua, 23,"coroutine finished"
10:58:22.004640Z, external/envoy/source/extensions/filters/common/lua/lua.h:149,envoy lua, 23,"creating N5Envoy10Extensions11HttpFilters3Lua16HeaderMapWrapperE
10:58:22.004627Z, external/envoy/source/extensions/filters/common/lua/lua.h:149,envoy lua, 23,"creating N5Envoy10Extensions11HttpFilters3Lua19StreamHandleWrapperE
10:58:22.004462Z, external/envoy/source/common/http/http2/codec_impl.cc:1850, 57, envoy http2, 23,"Http2Visitor::OnEndHeadersForStream(5141)"
10:58:22.004434Z, external/envoy/source/common/http/http2/codec_impl.cc:1397, 57, envoy http2, 23,"track inbound frame type=1 flags=4 length=2 padding_length=0"
10:58:22.004429Z, external/envoy/source/common/http/http2/codec_impl.cc:1115, 57, envoy http2, 23,"about to recv frame type=1, flags=4, stream_id=5141"
10:58:22.004423Z, external/envoy/source/common/http/http2/codec_impl.cc:1806, 57, envoy http2, 23,"Http2Visitor::OnFrameHeader(5141, 2, 1, 4)"
Server side logs:
Successful request:
12:59:33.929200238Z,"http2: Framer 0xc001192000: wrote HEADERS flags=END_STREAM|END_HEADERS stream=425 len=2"
12:59:33.929118668Z,"http2: Framer 0xc001192000: wrote DATA stream=425 len=11122 data=""\x00\x00\x00xxxxx"" (10866 bytes omitted)"
12:59:33.929092908Z,"http2: Framer 0xc001192000: wrote HEADERS flags=END_HEADERS stream=425 len=2"
12:59:33.925353278Z,"http2: Framer 0xc001192000: read PING flags=ACK len=8 ping=""\x02\x04\x10\x10\t\x0e\a\a""
12:59:33.924593249Z,"http2: Framer 0xc001192000: wrote PING len=8 ping=""\x02\x04\x10\x10\t\x0e\a\a
12:59:33.924577269Z,"http2: Framer 0xc001192000: wrote WINDOW_UPDATE len=4 (conn) incr=144"
12:59:33.924501198Z,"http2: Framer 0xc001192000: read DATA flags=END_STREAM stream=425 len=0 data=""
12:59:33.924444109Z,"http2: Framer 0xc001192000: read DATA stream=425 len=16 data=""\x00\x00\x00xxxx
12:59:33.924386618Z,"http2: decoded hpack field header field ""x-envoy-attempt-count"" = ""1
12:59:33.924383198Z,"http2: decoded hpack field header field ""x-request-id"" = ""xxx
12:59:33.924378498Z,"http2: decoded hpack field header field ""x-forwarded-proto"" = ""http
12:59:33.924375409Z,"http2: decoded hpack field header field ""te"" = ""trailers
12:59:33.924371898Z,"http2: decoded hpack field header field ""content-type"" = ""application/grpc
12:59:33.924368589Z,"http2: decoded hpack field header field ""user-agent"" = ""grpc-node-js/1.12.5
12:59:33.924365389Z,"http2: decoded hpack field header field ""grpc-timeout"" = ""2000m
12:59:33.924362558Z,"http2: decoded hpack field header field ""accept-encoding"" = ""identity
12:59:33.924358429Z,"http2: decoded hpack field header field ""grpc-accept-encoding"" = ""identity,deflate,gzip
12:59:33.924353909Z,"http2: decoded hpack field header field "":scheme"" = ""http
12:59:33.924350618Z,"http2: decoded hpack field header field "":path"" = ""/api.xxx_backend.xxxDataService/GetxxxData
12:59:33.924345129Z,"http2: decoded hpack field header field "":method"" = ""POST
12:59:33.924341729Z,"http2: decoded hpack field header field "":authority"" = ""xxx.xxx-backend:6002
Example of a failed request
12:59:33.868642633Z,"http2: Framer 0xc001192000: wrote RST_STREAM stream=423 len=4 ErrCode=NO_ERROR"
12:59:33.868631073Z,"http2: Framer 0xc001192000: wrote HEADERS flags=END_STREAM|END_HEADERS stream=423 len=2"
12:59:33.868614723Z,"http2: Framer 0xc001192000: wrote DATA stream=423 len=11122 data=""\x00\x00\x00xxxxx"" (10866 bytes omitted)"
12:59:33.868556433Z,"http2: Framer 0xc001192000: wrote HEADERS flags=END_HEADERS stream=423 len=2"
12:59:33.863568134Z,"http2: Framer 0xc001192000: read DATA stream=423 len=16 data=""\x00\x00\x00xxxx""
12:59:33.863273354Z,"http2: Framer 0xc001192000: read HEADERS flags=END_HEADERS stream=423 len=213"
12:59:33.863196083Z,"http2: decoded hpack field header field ""x-forwarded-client-cert"" = ""xxxxxxxxxxxxx
12:59:33.863187903Z,"http2: decoded hpack field header field ""x-envoy-attempt-count"" = ""1
12:59:33.863176054Z,"http2: decoded hpack field header field ""x-forwarded-proto"" = ""http
12:59:33.863170943Z,"http2: decoded hpack field header field ""te"" = ""trailers
12:59:33.863165394Z,"http2: decoded hpack field header field ""content-type"" = ""application/grpc
12:59:33.863160394Z,"http2: decoded hpack field header field ""user-agent"" = ""grpc-node-js/1.12.5
12:59:33.863155023Z,"http2: decoded hpack field header field ""grpc-timeout"" = ""1999m
12:59:33.863148454Z,"http2: decoded hpack field header field ""accept-encoding"" = ""identity
12:59:33.863143443Z,"http2: decoded hpack field header field ""grpc-accept-encoding"" = ""identity,deflate,gzip
12:59:33.863137983Z,"http2: decoded hpack field header field "":scheme"" = ""http
12:59:33.863132514Z,"http2: decoded hpack field header field "":path"" = ""/api.xxx_backend.xxxDataService/GetxxxData
12:59:33.863125494Z,"http2: decoded hpack field header field "":method"" = ""POST
12:59:33.863120914Z,"http2: decoded hpack field header field "":authority"" = ""xxx.xxx-backend:6002
Any help would be appreciated.
Thanks.
[optional Relevant Links:]
grpc/grpc-go#7623
grpc/grpc-node#2569
Activity
alyssawilk commentedon Jan 27, 2025
cc @wbpcode for lua @yanavlasov for gRPC concerns
github-actions commentedon Feb 26, 2025
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.
inrdkec commentedon Feb 27, 2025
Hi there,
Too add some context, we have seen that the Golang server is quite fast (i.e. 5 ms) and both Envoy sidecars (15ms and 17ms) and the NodeJS Client (30ms) are slower.
We have seen many streams were finished using RST_STREAM NO ERROR (which is valid and legitimate in the HTTP2) due to the slowness of the NodeJS clients response.
any idea what it could lead this issue?
Thanks.
github-actions commentedon Mar 29, 2025
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.
github-actions commentedon Apr 5, 2025
This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.
haorenfsa commentedon Jun 9, 2025
run into the same issue
inrdkec commentedon Jun 9, 2025
Hi @haorenfsa,
as this issue was not further investigated by the community and was automatically closed, the only solution I could find it was to switch the grpc libraries from Google's grpc implementations to connecrpc grpc implementation on both client (NodeJS/Typescript) and server (Golang): https://connectrpc.com/
After the switch no issues with Istio/envoy on the client side (NodeJS). The only downside is the latency which increased a bit 10-20%, and of course the time invested to switch the libraries and the monitoring/observability associated with the change.
I hope this help you.
Cheers.
haorenfsa commentedon Jun 9, 2025
Hi, @inrdkec
Thank you so much for providing a possible solution. But if this is a violation of grpc protocol, then we should try to fix it in envoy. Or did I get the wrong picture?
inrdkec commentedon Jun 10, 2025
Hi @haorenfsa,
In my case, I experienced random errors only in the client side (NodeJS). NodeJS under the hood is using libraries such as nghttp2 (also envoy), and the server was terminating many of the calls using RST_STREAM code 0. So this seems to me more a race condition in the grpc implementations, but this is just a guess. Unfortunately I did not get any reply from the community and the issue is closed. But you are welcome to push this topic to the community if you want.
Cheers.
haorenfsa commentedon Jun 11, 2025
@inrdkec , thank you so much for providing me some background. I tried fall back node-grpc to v1.7.3, and it actually works. So I'm thinking they must have introduce some bugs between v1.7.3 and v1.8.0.
haorenfsa commentedon Jun 11, 2025
I think we may simply fix this by changing some mechanism in the node-grpc lib. I guess there's not very much changes between these 2 versions.
haorenfsa commentedon Jun 11, 2025
btw, I found this issue provides many insights grpc/grpc-node#2569
inrdkec commentedon Jun 12, 2025
Yes, and I reported this here: grpc/grpc-node#2569 (comment)
Yes, I have added many posts in this issue. The main grpc-js developer sugested that the issue is on the istio(envoy) side and not in the library.
The issue seems quite simple at first but then it gets more and more difficult to debug. My guess, there is a race condition between NodeJS while working with Istio/envoy when the server is closing many of the calls with RST_STREAM code 0 (possible because grpc-go is much faster than grpc-js).
haorenfsa commentedon Jun 21, 2025
I agree, so I'll try fix #36200 first
ggreenway commentedon Apr 28, 2026
I'm working on a fix for this.
upstream: correctly handle h2 and h3 stream resets with no error (#44749
upstream: correctly handle h2 and h3 stream resets with no error (env…