Search code examples
pythonsocketsgrpc

gRPC server in Python with Unix domain socket


Will gRPC support in Python allow me to implement a server that listens on a Unix domain socket (as opposed to a port)? I am using Python 3.5.3 and grpcio/grpcio-tools 1.18.0.

So far, I have not been able to find any relevant example nor direct evidence. The official examples use server.add_insecure_port('[::]:50051'), and its not clear how a socket could fit there.


Solution

  • Apparently add_insecure_port(address) accepts Unix domain sockets in the format unix:///var/run/test.sock after all.

    More details: https://github.com/grpc/grpc/blob/master/doc/naming.md