Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No events when using server-side streaming RPC with React Native (with mode=grpcweb) #1345

Closed
VincentMarnier opened this issue Jun 26, 2023 · 3 comments

Comments

@VincentMarnier
Copy link

Hello,
I am using grpc-web with React Native for my client and ASP.NET + Grpc.AspNetCore.Web package for my server.
So far unary calls work wonderfuly, yet when I try to use server-side streaming RPC, I receive no events.
If the server ends the connection, every events from the begining of the connection are raised all at once.
It feels like events are not flushed as soon as possible or something.
My problem seems not to come from the server as it works if I am using grpc-web from a C# client (source: https://learn.microsoft.com/en-us/aspnet/core/grpc/grpcweb?view=aspnetcore-7.0#configure-grpc-web-with-the-net-grpc-client).

My code exactly:

const chatClient = new ChatClient("my_hostname")
const request = new JoinRoomRequest();
request.setRoomid(roomId);
chatClient.joinRoom(request)
  .on('error', error => {
    console.log('ERROR!')
    console.error(error)
  })
  .on('metadata', metadata => {
    console.log('METADATA!')
    console.log(metadata);
  })
  .on("data", ev => {
    console.log('DATA!')
    console.log(ev)
  })
  .on('status', status => {
    console.log('STATUS!')
    console.log(status);
  })
  .on('end', () => {
    console.log('END!')
  });

ChatClient is generated using:
protoc -I=Chat/ --js_out=import_style=commonjs,binary:webclient/Chat/src/APIClient --grpc-web_out=import_style=typescript,mode=grpcweb:webclient/Chat/src/APIClient Chat/*.proto

Is there something I am missing?

@VincentMarnier
Copy link
Author

Just so you know, it works if I use mode=grpcwebtext and --js_out=import_style=commonjs instead of mode=grpcweb and --js_out=import_style=commonjs,binary.

I will stick with text for now so.
Not sure if it is an issue from grpc-web or if I misunderstood something out there.
I'm leaving it open in case it is a bug, feel free to close it if it is not!

@sampajano sampajano changed the title No events when using server-side streaming RPC with React Native No events when using server-side streaming RPC with React Native (with mode=grpcweb) Jun 27, 2023
@sampajano
Copy link
Collaborator

Hi thanks for the report!

Actually, i think what you've observed is expected — streaming is currently only supported with mode=grpcwebtext but not mode=grpcweb, as documented here.. :)

I'm sorry for the inconvenience but for now you need to use grpcwebtext if you want server streaming. :)

I'm closing this issue but feel free to reopen or follow up with more details if needed. Thanks!

@IamJignesh
Copy link

We are facing similar issue with our React Native for Windows project #1468

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants