grpc / grpc-web

gRPC for Web Clients
https://grpc.io
Apache License 2.0
8.65k stars 764 forks source link

client receives all the messages at once when using server-side streaming? #1092

Open sfariv opened 3 years ago

sfariv commented 3 years ago

Hi, I was wondering if that's still a expected behavior I am seeing? client receives all the messages at once when using server-side streaming

I noticed this feature was a WAI back in 2019 https://grpc.io/blog/state-of-grpc-web/#f20

I was wondering if this is still not supported?

saman-pasha commented 3 years ago

I also have this issue that client does not receive any messages when server sending messages and when the server closes the stream, client receives all messages

I tested this issue by go grpc stream client and works correctly and client receives messages when server send it

saman-pasha commented 3 years ago

Solved! just use grpcwebtext protoc --js_out=import_style=commonjs:. --grpc-web_out=import_style=commonjs,mode=grpcwebtext:. events/events.proto

sergiocampama commented 3 years ago

I noticed the same thing over a year ago, and got this patch on my fork (that I've been a bit lazy to put as a pr, my bad)

https://github.com/sergiocampama/grpc-web/commit/ebdf6795c94cbe6867077d98747206b7dff28f6a

sergiocampama commented 3 years ago

hadn't read that blog post before, wondering if this was an avenue explored and discarded for some reason

lukasmuller10 commented 2 years ago

Does this issue have some update? I'm with the same problem.

sampajano commented 2 years ago

Hi! Thanks for the report and sorry for the delay in response!

I don't believe this is expected.. 😃

If you follow our echo example, are you still observing the same behavior?

One possibility is that there is a firewall or proxy which is buffering the HTTP responses until the response is complete, in which case it would example why streaming doesn't work. Could it be something that's happening here?

Thanks! :)

Cupprum commented 2 years ago

Just to sum up, according to grpc, in grpcweb mode, you will receive all messages at once, when the stream closes. If you want to receive messages one by one you need to use the grpcwebtext mode.

So to solve this issue, you need to use different command (specifically the --grpc-web_out part), while generating files with protoc.