Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect to gRPC C++ InProcessChannel not from C++?

I'm trying gRPC as JNI alternative and the idea is to have gRPC service on C++ side and client connected on Java/Android side. In order to have the best possible performance i'd prefer to use in-process channel (open to your suggestions).

How can i connect to C++ gRPC server with InProcessChannel()? The problem is that i need to pass a name for Java's InProcessServerBuilder.

In C++ gRPC tests (eg. here) i can't find it's set and it makes me think InProcessChannel can be used in pure C++ only (both server and client are in C++). Is it still possible for C++ service and Java client?

PS. I was able to do it for Java-server + Java-client.

PPS. I've found a couple of similar QnAs eg. here but i wonder if there is still a way to make it working together (probably with some 3rd-party channel impl). Can it work over Unix Domain Sockets?

like image 711
4ntoine Avatar asked Oct 24 '25 19:10

4ntoine


2 Answers

The C++ and Java "in-process" transports weren't named appropriately for cases multiple languages are in the same process. The in-process transports only work within each individual language; the C++ and Java in-process transports can't interact.

You should use the normal HTTP/2 client/server.

While something like you want could exist, as maybe a "shared memory" transport, it is a significant amount of work and would see relatively little usage for the maintenance burden.

like image 188
Eric Anderson Avatar answered Oct 26 '25 12:10

Eric Anderson


I've accepted Eric's Anderson answer as correct. However it might be useful to know how i made it working with Unix Domain Sockets.

I had to patch netty for Android and use it. Pay your attention to some Android-specific permission notes.

like image 34
4ntoine Avatar answered Oct 26 '25 12:10

4ntoine



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!