Is it possible to get the actual connected endpoint from a channel? I use a nameResolverFactory to get multiple possible endpoints for my channel. After a connection is established I want to know with which endpoint.
1 Answers
1
votes
The Channel does not provide a way to know which endpoint is being used before issuing an RPC. Each RPC may use a different connection (e.g., with round robin load balancer), so it's not a meaningful question to the Channel.
But if you do an RPC, after receiving the response headers you can call (e.g., from an interceptor) clientCall.getAttributes() and then get Grpc.TRANSPORT_REMOTE_ADDR. That returns the endpoint address that particular RPC used.