grpc / grpc-web

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

Stream data callback not called till after last stream element sent #281

Closed ctoomey closed 6 years ago

ctoomey commented 6 years ago

I'm calling a grpc function with a stream response as shown in the serverStreamingEcho() example in the README, but even though the server sends a stream element every 1/2 second, my stream.on('data', ...) callback doesn't get called until after the whole stream has been sent down (then it gets called for each element). So it's not actually "streaming". I'm using the Envoy grpc-web filter.

Is there a special request header that needs to be sent or something else that needs to be done to get streaming to work? Thanks.

stanley-cheung commented 6 years ago
  1. Which platform, browser and browser version are you using?
  2. Are you able to run our pre-packaged Quick demo? Typing "4 Hello" into the box should stream 4 "Hello" messages 0.5 seconds apart back to the browser. If that works, we should see how the pre-packaged demo is different from yours. If even that doesn't work, then we should focus on which environment you are running your code from.
stanley-cheung commented 6 years ago

Also just as a guess, when you run the protoc-gen-grpc-web plugin, did you pass in mode=grpcwebtext? If you had passed in mode=grpcweb streaming won't work, yet.

ctoomey commented 6 years ago

Yep I used mode=grpcwebtext. Will change that tomorrow and confirm streaming works, thanks.

On Sep 6, 2018 3:05 PM, "Stanley Cheung" notifications@github.com wrote:

Also just as a guess, when you run the protoc-gen-grpc-web plugin, did you pass in mode=grpcwebtext? If you had passed in mode=grpcweb streaming won't work, yet.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/grpc/grpc-web/issues/281#issuecomment-419256306, or mute the thread https://github.com/notifications/unsubscribe-auth/ACJBPEY1qNOBw2HXXeeaP9xbgiytL5nHks5uYZwOgaJpZM4Wdu6C .

ctoomey commented 6 years ago

I meant I had used mode=grpcweb, I've confirmed it works when I use mode=grpcwebtext. What's the ETA for it working w/ mode=grpcweb and is there a tracking ticket for that? Thanks for your help.

stanley-cheung commented 6 years ago

Is there any particular reason you need to use mode=grpcweb?

ctoomey commented 6 years ago

Mainly we'd like to benefit from the smaller bandwidth needed for the binary messages, and seems that should normally be the default for grpc implementations.

On Fri, Sep 7, 2018 at 12:50 PM Stanley Cheung notifications@github.com wrote:

Is there any particular reason you need to use mode=grpcweb?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/grpc/grpc-web/issues/281#issuecomment-419547804, or mute the thread https://github.com/notifications/unsubscribe-auth/ACJBPHelGIpWWvLs0g_A_UvzG3CS6OXgks5uYs4JgaJpZM4Wdu6C .

stanley-cheung commented 6 years ago

I see. Currently, there are limitation on browsers on receiving partial binary data. See a more detailed comment here.

ctoomey commented 6 years ago

Got it, helpful to know that this won't be coming soon. Thanks for your help, closing this ticket.

fawdlstty commented 3 months ago

Also just as a guess, when you run the protoc-gen-grpc-web plugin, did you pass in mode=grpcwebtext? If you had passed in mode=grpcweb streaming won't work, yet.

Hello. Is there any new information for this issue?

sampajano commented 3 months ago

@fawdlstty Thanks for checking :)

Just to confirm, are you referring to the streaming support when mode=grpcweb?

fawdlstty commented 3 months ago

Just to confirm, are you referring to the streaming support when mode=grpcweb?

yes

sampajano commented 3 months ago

@fawdlstty Aha thanks for clarifying!

Actually there's been a related recent thread below: https://github.com/grpc/grpc-web/discussions/1409

Our previous understanding that streaming won't work with mode=grpcweb, but the above discussion is bringing the question of whether it might be made to work in some environments (or maybe it's already working).

Please feel free to follow the above thread and/or chime in if you wish.

Thanks :)

fawdlstty commented 3 months ago

@sampajano Thank you for your reply. I will keep an eye on this discussion

sampajano commented 3 months ago

@fawdlstty Great! You're welcome! 😃