Skip to content

Unix Domain Socket connection should use localhost authority header convention by default #442

@kriswuollett

Description

@kriswuollett

The grpcurl client fails to work with the Rust tonic-based server on a Unix domain socket because the server expects an authority header.

% grpcurl -vv -d @ -plaintext -unix -protoset REDACTED/descriptor.bin  REDACTED/service.socket REDACTED/Reverse <<EOM
{ "text": "Hello, world!" }
EOM

Resolved method descriptor:
rpc Reverse ( .REDACTED.ReverseRequest ) returns ( .REDACTED.ReverseResponse );

Request metadata to send:
(empty)

Response headers received:
(empty)

Response trailers received:
(empty)
Sent 1 request and received 0 responses
ERROR:
  Code: Internal
  Message: stream terminated by RST_STREAM with error code: PROTOCOL_ERROR

For example, I'm able to use the Swift gRPC client fine since it sets authority.

Both tonic/h2 and kubernetes use localhost as the authority when using Unix domain sockets. The grpcurl client should as well.

The workaround, however inconvenient, is to manually specify the authority as localhost:

% grpcurl -vv -d @ -plaintext -unix -protoset REDACTED/descriptor.bin -authority "localhost"  REDACTED/service.socket REDACTED/Reverse <<EOM
{ "text": "Hello, world!" }
EOM

Resolved method descriptor:
rpc Reverse ( .REDACTED.ReverseRequest ) returns ( .REDACTED.ReverseResponse );

Request metadata to send:
(empty)

Response headers received:
content-type: application/grpc
date: Fri, 26 Jan 2024 02:46:38 GMT

Estimated response size: 15 bytes

Response contents:
{
  "text": "!dlrow ,olleH"
}

Response trailers received:
(empty)
Sent 1 request and received 1 response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions