Skip to content

Cannot connect to AWS Redis in cluster mode. (Using ioredis it works) #3117

@jisaacks

Description

@jisaacks

Description

Here is my code:

import { createCluster } from "redis";

export async function makeClient() {
  const client = createCluster({ rootNodes: [ { url: process.env.REDIS_URL } ] })
  .on('error', err => {
    console.log('Redis Client Error', { err })
  }).connect()

  return client
}

This will not error but it hangs forever.

The REDIS_URL is formatted like: rediss://:XXXXXX@HOST:PORT?ssl_cert_reqs=optional

However it works if I use ioredis with this code:

import Redis from 'ioredis'

const [_, password, host, port] = process.env.REDIS_URL!.match(/rediss:\/\/:(.*)@(.*):(\d*).*/)!

const Cluster = new Redis.Cluster([
  {
    host,
    port: Number(port),
  }
], {
  dnsLookup: (address, callback) => callback(null, address),
  redisOptions: {
    password,
    tls: {}
  }
})

console.log({ Cluster })

Being that ioredis is depricated I would prefer to use this library. Is there a solution?

Node.js Version

v18.20.8

Redis Server Version

No response

Node Redis Version

No response

Platform

No response

Logs

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions