Skip to content

Redis create cluster issue #1782

Open
Open
@ellik95

Description

@ellik95

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions