Skip to content

Infinite wait while connecting to TLS protected cluster (AWS MemoryDB) #2477

Closed as not planned

Description

@DKurilo

Description

I know it's not exactly Redis related and I don't know if it's reproducible for Redis cluster.
But given an AWS MemoryDB cluster (that behaves as Redis at least in documentation) that is protected by TLS.
Have cluster defined as:

    this.redisCluster = createCluster({
      rootNodes: [
        {
          url: 'rediss://host:6379',
        },
      ],
      defaults: {
        username: options.username,
        password: options.password,
      },
    });
    await this.redisCluster.connect(); // it freezes here

Last line never resolves. Because by default we have minimizeConnections as false and then RedisCluster start checking all the slots and all other slots it checks without tls: true option. Possible solution is to use tls in case we have tls in rootNodes or at least to add this to documentation.
As workaround:

    this.redisCluster = createCluster({
      rootNodes: [
        {
          url: options.redisUrl,
        },
      ],
      defaults: {
        username: options.username,
        password: options.password,
        ...(options.redisUrl.startsWith('rediss')
          ? { socket: { tls: true } }
          : {}),
      },
    });

I don't know if it should be fixed, maybe it should be just described in documentation

Node.js Version

v18.16.0, v19.8.1

Redis Server Version

6.2.6

Node Redis Version

1.5.6

Platform

alpine linux, macOS

Logs

No response

Activity

  1. maslowivan commented on Apr 24, 2023

    @maslowivan

    Faced the same issue when using the github actions with actions/github-script

    To solve the problem I've added the disconnect and process.exit(0) like this:

    const Redis = require("ioredis");
    
    const client = new Redis("rediss://default:*****@***.upstash.io:31187");
    async function main() {
      const result = await client.get("foo");
      console.log("result", result);
      await client.disconnect();
      process.exit(0);
    }
    
    main();
  2. DKurilo commented on Apr 24, 2023

    @DKurilo
    Author

    @studentIvan , it's not related issue. It's even completely different package.
    But just for information:
    You have opened connection and you have to close it explicitly. If your app is still doesn't close, check other async processes and connections you have.

  3. leibale commented on Apr 24, 2023

    @leibale
    Contributor

    @DKurilo it should emit an error after connectTimeout has been reached (which should be 5000 by default). I'll debug it later.

  4. DKurilo commented on Apr 24, 2023

    @DKurilo
    Author

    @leibale , thank you.
    Tell me if I can help somehow.
    I can add more logs if you need and so on.
    If you think it's good idea to use for all slots the same tls as it's in connection string, I can create PR a bit later.
    P.S. and yes, it doesn't respect timeout for some reason. I didn't dig deep enough to find why.

  5. github-actions commented on Apr 30, 2026

    @github-actions

    This issue has been automatically marked as stale due to inactivity.
    It will be closed in 30 days if no further activity occurs.
    If you believe this issue is still relevant, please add a comment to keep it open.

  6. github-actions commented on May 30, 2026

    @github-actions

    This issue has been automatically closed due to inactivity.
    If you believe this issue is still relevant, please reopen it or create a new issue with updated information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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