Search code examples
pythonservergrpcgrpc-python

gRPC Python Server calling Client?


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?


Solution

  • 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.