如何为gRPC记录到服务器的客户端连接? [英] How to log client connection to server for gRPC?

查看:503
本文介绍了如何为gRPC记录到服务器的客户端连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How to log client connection to server for gRPC ?

这是在连接客户端时发生的事件,我应该能够获取一些基本信息,例如IP,版本并进行记录

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

从192.168.1.1 AppName开始的DATETIME连接

DATETIME connection from 192.168.1.1 AppName

gRPC/Protobuf界面版本控制

推荐答案

如今,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.

这篇关于如何为gRPC记录到服务器的客户端连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆