-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redis create cluster issue #1782
Comments
As described in the clustering guide:
node-specific properties should be listed in createCluster({
rootNodes: [{
url: `rediss://redis-region-0001-001.amazonaws.com:6379`
}, {
url: `rediss://redis-region-0001-002.amazonaws.com:6379`
}],
defaults: {
username: REDIS_USERNAME,
password: REDIS_PASSWORD
}
}); |
I had tried this also and the same thing happened! Could you please reopen the issue? |
@ellik95 It didn't work even when the username & password are in the |
Yes, with this code:
it is not connected. Only if I add the url of the master node to the defaults options works. Like this:
And I was wondering why is this needed. |
createCluster({
rootNodes: [{
url: `rediss://redis-region-0001-001.amazonaws.com:6379`
}, {
url: `rediss://redis-region-0001-002.amazonaws.com:6379`
}],
defaults: {
tls: true,
username: REDIS_USERNAME,
password: REDIS_PASSWORD
}
}); |
It's not working either and |
createCluster({
rootNodes: [{
url: `rediss://redis-region-0001-001.amazonaws.com:6379`
}, {
url: `rediss://redis-region-0001-002.amazonaws.com:6379`
}],
defaults: {
socket: {
tls: true
},
username: REDIS_USERNAME,
password: REDIS_PASSWORD
}
}); |
Unfortunately it is not working either. Only with the below code is:
|
Also when I connect I sometimes get the error |
Same issue as @ellik95. Connection through |
I'm having the same issue with elasticache and the However, when you do that it seems like it only connects to that node. If you try to access a key that gets sorted onto one of the other nodes you get the MOVED error. @leibale I see that you mentioned this issue on #1827 but I'm not sure how that would apply to solve this issue. My server has access to the elasticache nodes just fine, it can connect to any of them individually with |
@leibale oh, awesome! Do you have any idea when that might be pushed out in a release? |
@acb Sunday/Monday :) |
@leibale I just tried release 4.0.4 and unfortunately I'm still having the same problem. With the code
I see 'connecting to redis' in my logs but it seems to hang and never actually connects. If I update my defaults to be
Then in my logs I get 'connecting to redis' followed immediately by 'connected to redis', but the connection is only to the one redis server that's in the default. If I try to sample random keys 2/3rds of them return with something like |
@acb try this const client = createCluster({
rootNodes: [
{
url: "rediss://redis-1-url:6379",
},
{
url: "rediss://redis-2-url:6379",
},
{
url: "rediss://redis-3-url:6379",
},
],
defaults: {
password: "password123",
socket: { tls: true }
}
}); |
@leibale you're a wizard! That did it, I'm getting successful cluster connections now. I thought that having Thanks so much for the help! |
For me, I found both the :6379 and the extra s in rediss:// to be unnecessary. This worked:
|
I am still getting the Error
I do get the output : "client connected" and "PONG". |
This is to way to connect for above issue.
|
Has this ever been addressed? I can't go to production with MemoryDB if this isn't fixed, and the approaches noted here result in an infinite loop of trying connection to localhost. |
@nibblesnbits none of these worked for you? wanna share some code? |
Well it looks like lack of sleep and attention to detail killed me. I missed that the call was But now I'm curious; is it more correct to use the cluster(s)' hostname, or the individual nodes? Seems logical that the latter is more correct. |
For anyone trying to connect to a MemoryDb cluster using TLS, this has proven to be the solution:
AFAIK you want to use the cluster hostname(cluster endpoint), especially for MemoryDb where you may add or delete nodes dynamically. |
@killdash9 correct. Not sure what the implications are, but With those changes in mind, my code now becomes: import { createCluster } from "redis";
const socket = {
tls: true,
rejectUnauthorized: false, // Disable certificate validation
};
// Assuming you're using a Redis client that supports cluster mode and TLS
const redisClient = createCluster({
rootNodes: [
{
url: "redis://<shard #1, node #1 endpoint>",
},
{
url: "redis://<shard #2, node #1 endpoint>",
},
{
url: "redis://<shard #3, node #1 endpoint>",
},
],
defaults: {
password: "TODO",
socket,
},
});
// Handle errors
redisClient.on("error", (err) => {
console.error("Redis Cluster Error", err);
});
// Connect to the cluster
await redisClient.connect().catch(console.error); Example of
|
Hello,
I have a Redis MemoryDB cluster with 2 nodes in AWS and I'm trying to connect to it through
createCluster
, but the connection isn't established.Here is how I try to connect:
The log
connected to cluster...
is never showed up.If I add in the configuration of
createCluster
to thedefaults
option the master node endpoint like this:The connection is established and everything works fine!
Why do I need the defaults option? Shouldn't it work only with rootNodes?
Thank you!
Environment:
The text was updated successfully, but these errors were encountered: