grpc-dart
grpc-dart copied to clipboard
Web Streaming doesn't work properly in K8s
When deploying the sample application to kubernetes, and doing the echo stream, it seems that all of the responses are buffered until the connection is closed.
However, when running against a local setup, or when using a standard gRPC (non-web) implementation against the same envoy sitting in k8s, the responses are properly streamed.
Maybe some header is missing from the web version that's forcing the intermediate loadbalancer to cache the responses? This was tested on both AKS and GKE.
So essentially any long lived stream doesn't work. Until a fix is in place, it might be valuable to put this in the docs (we spent some time investing in this and need to revert)
also happy to help provide k8s yaml files, envoy logs, etc to help debug
We have a test that verifies that streaming works in browser when talking gRPC-Web protocol proxied by envoy (see https://github.com/grpc/grpc-dart/blob/master/test/grpc_web_test.dart#L37-L54). Releases 2.2.0 and 2.2.0+1 had broken streaming though - please check that you were not using that. 2.3.0 should have fixed it.
I would suspect one of these two things:
- Browser issue: we are doing a hack overriding mime type on the XHR to enable streaming (which under normal conditions does not work for XHR returning binary data). Maybe this hack is broken in some browsers. So please include browser version that was used for testing.
- Something is wrong with load balancer not streaming binary responses through. Try looking in the Dev Tools in your browser - do you see connection established? do you see the data streaming in?
The gRPC version? I have grpc: ^2.8.0 in my pubspec.yaml
to quickly reply to the 2nd point, I saw data streaming back from my server to the envoy proxy succesfully, but not sure what envoy was doing with the data.
My client had the connection open and then would time out without receiving any responses if it took too long, or receive all the responses at once.
As a side note, on a more complicated application I have a long-lived streaming response, so it just always times out as we don't terminate the connection.
It works as expected when connecting directly to envoy, so I'm guessing it's a loadbalancer thing.. although the loadbalancer works when using vanilla grpc