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

C++ Asynchronous Streaming RPC example #10013

Closed
eduherminio opened this issue Mar 7, 2017 · 6 comments

Comments

Projects
None yet
6 participants
@eduherminio
Copy link
Contributor

commented Mar 7, 2017

Hi everybody,

Could anyone add/post a (simple) example which uses a both streaming and asynchronous RPC?
There are async examples (greeter_async_client & greeter_async_server in helloworld) without streaming; and streaming examples (in routeguide) but synchronous.

I'm having a hard time implementing a simple Server streaming, asynchronous RPC using C++.

Thanks in advance,

Eduardo

Edit:
What I am really seeking is to do something else in the server appart from attending its clients, while keeping an open stream with them (so that I can decide to send them new info when necessary); and that's why I thought a Asynchronous Streaming RPC could solve my problem.

  • With a synchronous, streaming RPC (routeguide example) I'm not being able to keep the connection opened in the server so that a new data stream can eventually be sent to the client (I need to send them data when received from somewhere else).

  • With an asyncrhonous, non streaming RPC (helloworld example) I'm being unable to do anything else in the server appart from attending its clients (for example, generating new data to be sent). Here is the HandleRpcs() function included in greeter_async_server example and the while(true) loop with GPR_ASSERT() that stops me from doing anything else

  void HandleRpcs() {
    new CallData(&service_, cq_.get());
    void* tag;  // uniquely identifies a request.
    bool ok;
    while (true) {
      GPR_ASSERT(cq_->Next(&tag, &ok));
      GPR_ASSERT(ok);
      static_cast<CallData*>(tag)->Proceed();
    }
  }

#6504

@eduherminio eduherminio changed the title C++ Asynchronous streaming example C++ Asynchronous Streaming RPC example Mar 7, 2017

@makdharma

This comment has been minimized.

Copy link
Contributor

commented Mar 7, 2017

#8934 Please take a look at this PR and add your comments there.

@AspirinSJL

This comment has been minimized.

Copy link
Member

commented Dec 11, 2017

Assigning to @vjpai because he has been doing the code review for #8934.

@vjpai

This comment has been minimized.

Copy link
Member

commented May 15, 2018

There are more examples now along with a lot more documentation.

@vjpai vjpai closed this May 15, 2018

@lucifercr07

This comment has been minimized.

Copy link

commented Aug 31, 2018

How to keep the async stream connection alive?
E.g: rpc Test (request) returns (stream response) {}

I want to keep connection alive even after getting response from server.

@lucifercr07

This comment has been minimized.

Copy link

commented Sep 12, 2018

There are more examples now along with a lot more documentation.

@vjpai Can you please point out the examples?

@andygikling

This comment has been minimized.

Copy link

commented Sep 17, 2018

Bump,

@vjpai What examples are you talking about? The latest grpc tag 1.15 does not provide a c++ async bidi example. #8934 is the only good example I've seen but it's not done.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 16, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.