0

I think I understand the client-server structure in gRPC, but don't know how to enable the server to call RPCs on the client. Do I implement both Client & Server (figure both server & stubs) on both sides and have 2 separate channels afterwards or is there a feature I missed?

6
  • Have you tried running the client/server examples? Here's the official Python tutorial and their sets of examples. You generally have one process for the server, and however many clients you want. The clients create a channel to the server, create a stub with the channel, and then call the RPC on the stub. Commented Jan 4, 2021 at 20:07
  • Sorry, made a mistake in the question. Yes, I tried those and they behave as expected. However, I need the server to be able to call the clients. Commented Jan 4, 2021 at 20:17
  • Can you give a little more explanation of what you want to do? It isn't clear if you want a client-streaming RPC or if you actually need a server on both ends. Commented Jan 4, 2021 at 20:21
  • I'll probably have to use a server on both ends. If an event happens on the client, it calls the server for information about other clients. Simultaneously the other clients need to receive the updated information from the server about the original client. Commented Jan 4, 2021 at 20:27
  • @mostermann if my answer helped you,you can accept it by clicking the gray checkmark next to it Commented Jan 4, 2021 at 20:28

1 Answer 1

1

No. A server cannot invoke a call on the client. Here is a quote from a question I found on SO: Can both ends of a gRPC connection accept method calls?

gRPC works with HTTP, and HTTP has not had such semantics in the past.

There has been discussion as to various ways to achieve such a feature, but I'm unaware of any work having started or general agreement on a design. gRPC does support bidirectional streaming, which may get you some of what you need. With bidirectional streaming the client can respond to messages from server, but the client still calls the server and only one type of message can be sent for that call.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your quick answer, I feared that that would be the case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.