grpc/grpc-dotnet

GrpcChannel for unix domain sockets without http uri

isaksky opened this issue · 1 comments

Hi, I'm following the advice here in the documentation for creating GrpcChannels for unix domain sockets:

public static readonly string SocketPath = Path.Combine(Path.GetTempPath(), "socket.tmp");

public static GrpcChannel CreateChannel()
{
    var udsEndPoint = new UnixDomainSocketEndPoint(SocketPath);
    var connectionFactory = new UnixDomainSocketsConnectionFactory(udsEndPoint);
    var socketsHttpHandler = new SocketsHttpHandler
    {
        ConnectCallback = connectionFactory.ConnectAsync
    };

    return GrpcChannel.ForAddress("http://localhost", new GrpcChannelOptions
    {
        HttpHandler = socketsHttpHandler
    });
}

This works, but the "http://localhost" causes problems when running on docker. The problem is it looks like that uri gets validated and even connected to when the channel gets constructed, and then it gives an error.

Is there a way to create a GrpcChannel for a unix domain socket without specifying a http uri? I would think a http uri shouldn't enter into it if a unix domain socket is used.

I was seeing some strange errors, but now I'm not sure this was the problem. I'll close this one, maybe open a new one if I get more details.