Uniquely identifying clients in gRPC c++

44 views
Skip to first unread message

Sachin Bharadwaj S

unread,
Aug 12, 2020, 7:28:05 AM8/12/20
to grpc.io

I am implementing gRPC server application and multiple clients are connected to my server and starts to call RPCs.


How can the server uniquely identify which client is calling the RPC?


Let us assume that server exposes a register RPC and client is implemented in such a way that it calls the register API only once and at the start of the client.


Let us also assume that the server guarantees to generate and assign a unique ID for each client in the register RPC.


For example,

Client A -> ID=1

Client B -> ID=2


Is there a way to get back the ID associated with the client when an RPC is called?


We do not want to send the ID to the client and ask the client to send the same ID in all the further RPCs which leads to change in the .proto file.

How can this be handled in gRPC?


Can I keep this sticky ID somewhere in the context and get back in all the RPC associated with the same client?

Mya Pitzeruse

unread,
Aug 12, 2020, 11:05:05 AM8/12/20
to Sachin Bharadwaj S, grpc.io
You can generate a UUID in code, but that will only be valid for the length of deployment. This could be passed in as an option to your client. The best way to identify clients and do it securely is using mTLS (which gRPC does support).

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/d77ee459-64c8-4730-836d-670878d63948o%40googlegroups.com.


--

Mya Pitzeruse

Principal Software Engineer - Service Infrastructure

Gender Pronouns: She, Her, Hers

mjp...@indeed.com


Indeed - We help people get jobs.

Indeed.com


Facebook  |  Twitter  |  Instagram

Sachin Bharadwaj S

unread,
Aug 17, 2020, 1:33:16 AM8/17/20
to Mya Pitzeruse, grpc.io
Hi Mya,

Thanks for your response.

I was planning to generate a unique ID for each client in the register RPC and send the same in the metadata.
The client can cache that value and pass it in all further RPCs so that server can identify it.

Regards,
Sachin

Reply all
Reply to author
Forward
0 new messages