2
votes

how exactly does grpc streaming work over reverse-proxies? My understanding is that persistent connections will be made between the client and the reverse proxy, while the connection between the the reverse proxy and my server is not persistent -- so how can my actual servers, sitting behind the reverse proxy, continue to stream messages to the client over the persisted connection?

Also, let's say I want to keep around the persistent connections for handling push notifications (i.e. my server keeps track of the persistent connections, something happens on my server side where i want to notify a particular client, I get the stream / persistent connection for that particular client then send a message over it).

1

1 Answers

3
votes

gRPC streams use HTTP/2 streams. HTTP/2 streams are bound to the TCP connection they are started on. A reverse proxy will create an HTTP/2 stream to the backend to forward the RPC. So the "stream" will be bound to two TCP connections: client → proxy, proxy → backend. If either TCP connection is closed then the RPC will be cancelled. With HTTP/2, even reverse proxies have a semi-persistent connection to the backend, but it is true they may cycle the connection more frequently than a client may.