Paul Verest
Paul Verest

Reputation: 63912

How to log client connection to server for gRPC?

How to log client connection to server for gRPC ?

That is on event when a client is connected, I should be able to get some basic information, like IP, version and log it

DATETIME connection from 192.168.1.1 AppName

Related to gRPC / Protobuf interface versioning

Upvotes: 2

Views: 3724

Answers (1)

Eric Anderson
Eric Anderson

Reputation: 26414

Today, IP address and version is available on a per-RPC basis, but not when the client connects. You can use serverCall.attributes().get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR) to get the IP address and the version is included in the User-Agent metadata.

Issue 2312 (v1.1) will add a mechanism to be notified of new connections. It would have access to the IP address of the client, but it wouldn't know the client version. Client version is only known on a per-RPC basis, due to things like proxies.

Upvotes: 3

Related Questions