I am trying to deploy a simple NodeJS application which is HTTP2(H2) enabled, this is working fine locally
Here is my NodeJS code
const spdy = require('spdy')
const express = require('express')
const path = require('path')
const fs = require('fs')
const port = 8080
const CERT_DIR = `${__dirname}/cert`;
const app = express()
app.get('*', (req, res) => {
res
.status(200)
.json({message: 'Welcome to node HTTP2'})
})
const options = {
key: fs.readFileSync(`${CERT_DIR}/server.key`),
cert: fs.readFileSync(`${CERT_DIR}/server.crt`)
}
spdy
.createServer(options, app)
.listen(port, (error) => {
if (error) {
console.error(error)
} else {
console.log('Listening on port: ' + port + '.')
}
})
I have created self signed certificate and key using openssl command, here is the output in the browser locally
but after I deploy it to cloud run and enable use HTTP/2 end-to-end as shown below.
It gives me the below response
I have checked the logs of cloud run, and the error message says The request failed because either the HTTP response was malformed or connection to the instance had an error. Additional troubleshooting documentation can be found at: https://cloud.google.com/run/docs/troubleshooting#malformed-response-or-connection-error
If you ask me, why am I turning my app into HTTP2, it is because I want to make request of size more than 32MB, which is a limitation of cloud run if you are using HTTP/1 server
my question is, is it possible to deploy my NodeJS app with HTTP/2 server enabled to cloud run ? if so where exactly have I gone wrong above?
my curl output of localhost url
my curl output of cloud run url










Based on this documentation on using HTTP/2 (services):
To confirm that your service supports
h2crequests, test the service locally using this cURL command:EDIT:
Since you're using a self-signed certificate and CA wasn't able to verify the legitimacy of the server, there are workarounds that you may perform in order to disable strict certificate checking:
You may use the
-kswitch to disablecurlstrict certificate checking.You may also use
--insecure, achieving the same result.Or, you can disable SSL certificate validating by writing it to
.curlrcconfiguration file.You may check the documentations below for your reference: