grpc / grpc/grpc-node

Error: Failed to connect before the deadline.

Open
#2,906 2 comments 0 reactions 0 assignees View on GitHub
package: @grpc/grpc-js
Dominant language
TypeScript
Stars
4.8k
Forks
716
Avg merge
2d 3h
Merged PRs (30d)
10

Description

What version of gRPC and what language are you using?
gRPC version = 1.8.14, Language = javascript;

What operating system (Linux, Windows,...) and version?
Linux

What did you do?
Please provide either
I have been using gRPC for a long time. I was using it with an inscure connection. Then we decided to make the connection secure using mtls.
I tested it in my local system and I am able to connect it securely but when I moved it to the server it started facing error. I have no clue how to debug it further.
The error I keep getting is Error: Failed to connect before the deadline.

This is what I have added in the code for server

const credentials = grpc.ServerCredentials.createSsl(fs.readFileSync(String(process.env.GRPC_NOTIFICATION_CA_CERT)), [{
cert_chain: fs.readFileSync(String(process.env.GRPC_NOTIFICATION_SERVER_CERT)),
private_key: fs.readFileSync(String(process.env.GRPC_NOTIFICATION_SERVER_KEY))
}], true);

server.addService(package.service, {
youService
});

server.bindAsync("0.0.0.0:3006", credentials, (err) => {
if (err) {
console.error(err);
return;
}
console.log("GRPC server running at port 3006");
server.start();
});

client code

const credentialsClient1 = grpc.credentials.createSsl(
fs.readFileSync(String(process.env.GRPC_NOTIFICATION_CA_CERT)),
fs.readFileSync(String(process.env.GRPC_NOTIFICATION_CLIENT_KEY)),
fs.readFileSync(String(process.env.GRPC_NOTIFICATION_CLIENT_CERT))
);
const client2 = new package("notification-srv:3005", credentialsClient1);

client2?.waitForClientReady(Date.now() + 5000, (err) => {
if (err) {
console.error(err);
}
else {
console.info("GRPC client connected");
}
});
Another thing I am using Kubernetes for my application.

What did you expect to see?
It should have gotten connected since I am passing a valid certificate.

What did you see instead?
It is giving me error

Copied over from https://github.com/grpc/grpc/issues/38820
@shubham-rapidops

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.