Utilizing WebSockets on Cloud Run doesn’t require any further configuration and works out of the field. To make use of client-side streaming or bidirectional streaming with gRPC, you’ll want to allow HTTP/2 assist, which we discuss within the subsequent part.
It is price noting that WebSockets streams are nonetheless topic to the request timeouts configured in your Cloud Run service. For those who plan to make use of WebSockets, be sure to set your request timeout accordingly.
Finish-to-end HTTP/2 assist
Though many apps don’t assist it, Cloud Run has supported HTTP/2 since its first launch, together with end-to-end HTTP/2 for gRPC. It does so by routinely upgrading shoppers to make use of the protocol, making your providers sooner and extra environment friendly. Nonetheless, till now, HTTP/2 requests have been downgraded to HTTP/1 after they have been despatched to a container.
Beginning right this moment, you should utilize end-to-end HTTP/2 transport on Cloud Run. That is helpful for purposes that already assist HTTP/2. For apps that don’t assist HTTP/2, Cloud Run will merely proceed to deal with HTTP/2 visitors up till it arrives at your container.
On your service to serve visitors with end-to-end HTTP/2, your utility wants to have the ability to deal with requests with the HTTP/2 cleartext (often known as “h2c”) format. We have now developed a sample h2c server utility in Go so that you can check out the “h2c” protocol. You may construct and deploy this app to Cloud Run by cloning the linked repository and working: