0

I'm developing a gRPC application using Python and the basic grpc library as well as proto. In my client I can easily specify a port and host when creating a channel, but when creating a server like so server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) I can't find any way to specify a host. I can add ports to the server via server.add_insecure_port(port info)but am totally stumped on specifying a host. I've combed through the documentation here and here, and have looked through any relevant queries elsewhere, but I can't find a solution. The closest I can find is this asyncio/grpclib library that has this functionality, but I don't want to use this as the gRPC library seems perfect for my use case. Is there any way I can pass in a host?

4
  • 1
    server.add_insecure_port() accepts port as address like "localhost:9000" or "0.0.0.0:9000" Commented Sep 23, 2022 at 11:39
  • @Kris Does that mean the host is included in add_insecure_port as well? Commented Sep 23, 2022 at 11:50
  • 1
    Yes. As per my understanding it accepts a qualified address, not just a port. Commented Sep 23, 2022 at 12:22
  • You need to specify a server host on the client (host) because the two may be on different hosts. A server (running on a host) may want to specify which of its host's IP addresses or, commonly all interfaces (i.e. [::] which is I think an alias for 0.0.0.0) it will use and @kris comment explains how to do this but the only way you can "specify a host for a server" is when you decide on which host you're going to deploy code (e.g. your server). Commented Sep 23, 2022 at 15:31

0

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.