akka-grpc icon indicating copy to clipboard operation
akka-grpc copied to clipboard

client: authority header missing port

Open fredfp opened this issue 4 years ago • 0 comments

The authority header is currently set to the service name, it should also include the port. Without the port, requests going through a proxy/load-balancer are not handled correctly as those rely on the port present in the authority header and default to e.g., 80 when it is missing (which often does not correspond to the actual port the server is listening to).

@pavlo-t for example reported in https://github.com/akka/akka-grpc/issues/898#issuecomment-672888538 that this behaviour made it hard to work with Linkerd (see notes there for similar issues in other projects).

I believe it is tricky to fix with the current design, at least when relying on service discovery (i.e., when using GrpcClientSettings.usingServiceDiscovery or GrpcClientSettings.fromConfig with service discovery enabled) because:

  • the doc of io.grpc.NameResolver#getServiceAuthority states that the authority must be generated without blocking AND must never be changed.
  • io.grpc.NameResolver#getServiceAuthority is called when the netty channel is .build() (io.grpc.internal.AbstractManagedChannelImplBuilder#build)
  • service discovery can be configured with a port name, which is only looked up asynchronously after the netty channel is built

I currently work around this using override-authority, which forces me to hardcode the server port number in the client rather than allowing me to rely on discovery by name.

fredfp avatar Sep 01 '20 10:09 fredfp