且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何为gRPC记录到服务器的客户端连接?

更新时间:2022-03-16 22:30:51

如今,IP地址和版本是基于每个RPC的,而不是在客户端连接时可用的.您可以使用serverCall.attributes().get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR)获取IP地址,并且版本包含在User-Agent元数据中.

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.

问题2312 (v1.1)将添加一种机制收到新连接通知.它可以访问客户端的IP地址,但不知道客户端版本.由于存在诸如代理之类的问题,因此仅基于每个RPC才知道客户端版本.

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.