You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This library enables using a subset of the functionality of a gRPC server even if it is exposed behind
5
-
a reverse proxy that does not support HTTP/2, or only supports it for clients (such as Amazon's ALB).
6
-
This is accomplished via adaptive downgrading to the gRPC-web response format. This library allows
7
-
instrumenting both clients and servers to that extent.
4
+
This library enables using all the functionality of a gRPC server even if it is exposed behind
5
+
a reverse proxy which does not support HTTP/2, or only supports it for clients (such as Amazon's ALB).
6
+
This is accomplished via either adaptive downgrading to the gRPC-Web response format or utilizing WebSockets.
8
7
9
8
For a high-level overview, see [this Medium post](https://medium.com/stackrox-engineering/how-to-expose-grpc-services-behind-almost-any-load-balancer-e9ebf8e6d12a).
10
9
10
+
**Stay tuned for a high-level overview article to the WebSocket solution.**
11
+
11
12
Connection Compatibility Overview
12
13
---------------------------------
13
14
@@ -19,18 +20,18 @@ when accessing it via a reverse proxy not supporting HTTP/2.
19
20
<tr><th></th><thcolspan="2">Plain Old gRPC Server</th><thcolspan="2">HTTP/1 Downgrading gRPC Server</th></tr>
The (:white_check_mark:) in the bottom right cell indicates that a subset of gRPC calls will be possible, but not
27
+
The (:white_check_mark:) for the gRPC-Web downgrading client indicates a subset of gRPC calls will be possible, but not
26
28
all. These include all calls that do not rely on client-side streaming (i.e., all unary and server-streaming calls).
27
-
Support for client-side streaming calls is active work in progress.
28
29
29
-
As you can see, it is possible to instrument the client or the server only without any (functional) regressions - there
30
+
As you can see, when using the client in gRPC-Web downgrade mode, it is possible to instrument the client **or** the server without any (functional) regressions - there
30
31
may be a small but fairly negligible performance penalty. This means rolling this feature out to your clients and
31
32
servers does not need to happen in a strictly synchronous fashion. However, you will only be able to work with a server
32
-
behind an HTTP/2-incompatible reverse proxy if both the client and the server have been instrumented via
33
-
this library.
33
+
behind an HTTP/2-incompatible reverse proxy if both the client **and** the server have been instrumented via
34
+
this library. To use the client in gRPC-WebSocket mode, both the client **and** server must be instrumented via this library.
34
35
35
36
36
37
Usage
@@ -48,7 +49,7 @@ and instead use the `ServeHTTP` method of the `*grpc.Server` object -- it is exp
48
49
to be fairly stable and reliable.
49
50
50
51
The only exported function in the `golang.grpc.io/grpc-http1/server` package is `CreateDowngradingHandler`,
51
-
which returns a `http.Handler` that can be served by a Go HTTP server. It is crucial that this server is
52
+
which returns a `http.Handler` that can be served by a Go HTTP server. It is crucial this server is
52
53
configured to support HTTP/2; otherwise, your clients using the vanilla gRPC client will no longer be able
53
54
to talk to it. You can find an example of how to do so in the `_integration-tests/` directory.
54
55
@@ -66,6 +67,10 @@ connection to the server, pass a `nil` TLS config; however, this does *not* free
66
67
`grpc.WithInsecure()` gRPC dial option.
67
68
68
69
The last (variadic) parameter specifies options that modify the dialing behavior. You can pass any gRPC dial
69
-
options via `client.DialOpts(...)`. Another important option is `client.ForceHTTP2()`, which needs to be used for
70
-
a plaintext connection to a server that is *not* HTTP/1.1 capable (e.g., the vanilla gRPC server). Again, check out the
70
+
options via `client.DialOpts(...)`; however, the `grpc.WithTransportCredentials` option will not be needed.
71
+
By default, adaptive gRPC-Web downgrading is used. To use WebSockets, pass `true` to the `client.UseWebSocket` option.
72
+
73
+
Another important option is `client.ForceHTTP2()`, which needs to be used for
74
+
a plaintext connection to a server that is *not* HTTP/1.1 capable (e.g., the vanilla gRPC server).
75
+
This option is ignored when WebSockets are used. Again, check out the
0 commit comments