Open
Description
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:
import { createCluster } from 'redis';
(async () => {
const REDIS_USERNAME = 'test-username';
const REDIS_PASSWORD = 'test-pass';
const cluster = createCluster({
rootNodes: [
{
url: `rediss://redis-region-0001-001.amazonaws.com:6379`,
username: REDIS_USERNAME,
password: REDIS_PASSWORD,
},
{
url: `rediss://redis-region-0001-002.amazonaws.com:6379`,
username: REDIS_USERNAME,
password: REDIS_PASSWORD,
},
]
});
cluster.on('error', (err) => console.log('Redis Cluster Error', err));
console.log('before connection');
await cluster.connect();
console.log('connected to cluster...');
await cluster.set('key', 'value');
const value = await cluster.get('key');
console.log(value);
await cluster.disconnect();
})();
The log connected to cluster...
is never showed up.
If I add in the configuration of createCluster
to the defaults
option the master node endpoint like this:
defaults: {
url: `rediss://redis-region-0001-001.amazonaws.com:6379`,
username: REDIS_USERNAME,
password: REDIS_PASSWORD,
}
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:
- Node.js Version: 16-alpine3.12
- Redis Server Version: 6
- Node Redis Version: 4.0.0