How to get client ip from request metadata with grpc-java
Client IP is not provided in Metadata. But you can call ServerCall.attributes() and get the Grpc.TRANSPORT_ATTR_REMOTE_ADDR.
Please note that the API is unstable and may change.
In latest (1.2.0) gRPC use io.grpc.Grpc.TRANSPORT_ATTR_REMOTE_ADDR
attribute in interceptor to get remote address.
if in python grpc, you will get client ip address and port using context.peer()
.
def your_method(self, request, context):
...
context.peer() # return 'ipv4:49.123.106.100:44420'
...