How to log client connection to server for gRPC?

孤人 提交于 2020-01-23 03:38:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!