gRPC binding the socket to a particular interface or device (Something like SO_BINDTODEVICE)

118 views
Skip to first unread message

Abhi Arora

unread,
Feb 25, 2020, 12:59:45 AM2/25/20
to grpc.io
I have a Linux Embedded Machine with gRPC cross-compiled for it. I am looking to create multiple instances of gRPC each bind to a particular interface or device. Linux POSIX socket provides SO_BINDTODEVICE option but I am not sure if gRPC has any application layer method or function to achieve it. I tried other forums but couldn't find something useful.

Is there any workaround to achieve the same thing?

Please help me.


Thomas Mercier

unread,
Feb 25, 2020, 10:18:00 AM2/25/20
to Abhi Arora, grpc.io
Have you tried listening on the address associated with each of the interfaces instead of 0.0.0.0 as in here?
https://github.com/grpc/grpc/blob/v1.27.0/examples/cpp/route_guide/route_guide_server.cc#L176

--
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/e60802cd-8319-4f52-bdda-0e113e2dc9ba%40googlegroups.com.

Abhi Arora

unread,
Feb 25, 2020, 10:40:28 AM2/25/20
to grpc.io
Pardon but I forgot to mention my setup is a gRPC client and the code you shared belongs to server sample.

Abhi Arora

unread,
Feb 26, 2020, 4:45:15 AM2/26/20
to grpc.io
My application communicates with gRPC server. Is there any way for gRPC client to bind to a particular interface or device? Or can I bind to particular IP? Will it work? Is there any way?

Linux POSIX socket provides SO_BINDTODEVICE option but I am not sure if gRPC has any application layer method or function to achieve it. I tried other forums but couldn't find something useful.

Is there any workaround to achieve the same thing?

On Tuesday, February 25, 2020 at 11:29:45 AM UTC+5:30, Abhi Arora wrote:

yas...@google.com

unread,
Feb 26, 2020, 1:39:56 PM2/26/20
to grpc.io
gRPC C++ does not have any API to allow the client to bind to a specific IP address at the moment.

Abhi Arora

unread,
Feb 27, 2020, 3:24:39 AM2/27/20
to grpc.io
Okay. So we don't have options to set "SO_BINDTODEVICE " or bind to a particular IP in C++ for gRPC Client? Both are not available? How about gRPC Python Client? We can think to move to gRPC python client.

Abhi Arora

unread,
Mar 3, 2020, 3:54:07 AM3/3/20
to grpc.io
Hello,
Any possible solution or any hack to achieve the same thing?


On Tuesday, February 25, 2020 at 11:29:45 AM UTC+5:30, Abhi Arora wrote:

Fazil Manzoor

unread,
Aug 25, 2020, 5:29:32 AM8/25/20
to grpc.io
Facing same issue on python grpc client and server
Reply all
Reply to author
Forward
0 new messages