0

I have a gRPC server written in C++ which is running on a server say Gabroo

Gabroo:~/grpc/examples/cpp/stream_server$ ./stream_server
DB parsed, loaded 1 features.
Server listening on 0.0.0.0:50051

The client is running on same server and exits after receiving the message.

Gabroo:~/grpc/examples/cpp/stream_server$ ./stream_client
DB parsed, loaded 1 features.
-------------- GetFeature --------------

Found feature called PatriotsPath,Mendham,NJ07945,USA at 40.7838, -74.6144
Found no feature at 0, 0

Now if the server wants to send a message to client but client is not listening for any message is there some configuration needed so that client is in listen mode continuously for stream messages from server.

If it is not available inbuilt would infinite loop and checking for message every 1 secs be a good approach. I personally don't like this approach.

Regards !!!

Vinay Shukla
  • 1,818
  • 13
  • 41
  • Possible duplicate of: https://stackoverflow.com/questions/49580793/how-to-broadcast-in-grpc-from-server-to-client/49697489#49697489 – Michał May 01 '18 at 21:44
  • Your client should listen to the server by listening a server streaming rpc such as `rpc NotifyMe (google.protobuf.Empty) returns (stream WakeupMessage)` – david May 10 '18 at 21:18

1 Answers1

0

This can be solved using RPCs of different arity. Most generally, you could define a bi directional stream between client and server. That way, if a stream is open, the client will be listening, ready to receive messages from the server.

If you use case is more specific, and you only need on client RPC per stream, then you could consider using Server streaming RPC.

Noah Eisen
  • 268
  • 1
  • 6