I have a Node.js gRPC service deployed on CloudRun, with the following configurations:
Continuous integration from Github with Dockerfile with which it creates docker container.
I have exposed port 8080 in the container, it's the same port configured on CloudRun to run the service.
I have allowed
Allow direct access to your service from the internet
so it can accept all requestsIn addition to all that I added HTTP/2 in network
The server is deployed well and works fine, I see the logs, and when I make http call on 8080 port it logs, that server couldn't respond to Chrome, Postman etc.
The problem is whenever I make a gRPC call the url of this service from the internet I get this error:
Here is my server code snippet
const { connect } = require("mongoose");
const { loadSync } = require("@grpc/proto-loader");
const { loadPackageDefinition, Server, ServerCredentials } = require("@grpc/grpc-js");
require('dotenv').config();
const sessionProto = './src/prototypes/session.proto';
const sessionService = require('./src/services/session');
const healthProto = './src/prototypes/health.proto';
const healthService = require('./src/services/health');
const protoLoaderOptions = {
oneofs: true,
longs: String,
enums: String,
keepCase: true,
defaults: true,
};
const healthPackageDefinition = loadSync(healthProto, protoLoaderOptions);
const healthProtoDefinition = loadPackageDefinition(healthPackageDefinition);
const sessionPackageDefinition = loadSync(sessionProto, protoLoaderOptions);
const sessionProtoDefinition = loadPackageDefinition(sessionPackageDefinition);
const server = new Server();
// Services
server.addService(healthProtoDefinition.HealthService.service, healthService);
server.addService(sessionProtoDefinition.SessionService.service, sessionService);
server.bindAsync(
`0.0.0.0:${process.env.PORT}`,
ServerCredentials.createInsecure(),
async (error, port) => {
if (error) {
console.error(error.message);
process.exit();
} else {
try {
await connect(process.env.MONGODB_URL);
console.log(`Server running at http://0.0.0.0:${port}`);
server.start();
} catch (e) {
console.error(e.message);
process.exit();
}
}
}
);
I searched all over the web, couldn't find the solution for this, I appreciate your help, thanks!
I tried all possible ports: 8080, 443 and 50051, couldn't get around it.
I expected it to return the response just fine as other tutorials show it, it seems straight foward and no one got this error before.
Thanks in advance for any help!