silb78
silb78

Reputation: 139

gRPC Java Client: get connected endpoint

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.

Upvotes: 0

Views: 749

Answers (1)

Eric Anderson
Eric Anderson

Reputation: 26474

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.

Upvotes: 1

Related Questions