问题
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
回答1:
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.
来源:https://stackoverflow.com/questions/40543439/how-to-log-client-connection-to-server-for-grpc