Cap
Cap

Reputation: 99

Multiple bi-directional gRPC calls over single pre-established TCP connection

Is it possible to use gRPC such that all calls between two remote hosts use a TCP connection that is established outside of gRPC? I would also like to determine whether this TCP connection can be multiplexed for more than one gRPC call, that the calls may be in either directions, and that gRPC not close the socket.

The intent is to be able to use gRPC when two ends of gRPC are across a firewall. The firewall only allows establishing a single TCP connection that is initiated from within the firewall.

For the requirements only C++ and Java implementations may be on either side.

Upvotes: 1

Views: 2186

Answers (1)

Eric Anderson
Eric Anderson

Reputation: 26414

Maybe. The main problem will probably be that you don't want gRPC to close the socket; it's unclear when you want gRPC to release the socket back to you. It's also unclear whether you need this on server-side or client-side.

gRPC uses HTTP/2 which can naturally multiplex multiple bi-directional calls over a single TCP connection. C++ also allows you to provide it an existing fd. Java doesn't support passing an fd out-of-the-box, but it should be possible using the JNI Netty EpollSocketChannel. I would only expect those to work on client-side today, though.

This may be something that deserves a GitHub issue as a feature request.

Upvotes: 2

Related Questions