Connection ElasticCache Redis Cluster to NodeJS ioredis

vsradical
Sun, 12 Nov 2023 04:47:31 +0000
Redis administration

Hey guys I’m having issues trying to get ioredis-clustering connected to a sample nodeJS instance. I am able to connect through redis-cli and call the SET/GET commands. The Redis cluster is hosted on AWS through ElasticCache. I have 3 shards with 1 master and 2 read. I am connecting locally to the nodes through AWS SSO and a Bastion EC2 instance. Not sure what I’m missing here. After a considerable amount of Googling and ChatGPT, I am stumped. Hoping someone here can lead me in the right direction. Any suggestions and help are much appreciated! Please let me know if there anything else I can add to this to help with debugging.

  const cluster = new Redis.Cluster(redis_nodes, {
    // dnsLookup: (address, callback) => callback(null, address),
    scaleReads: "slave",
    // slotsRefreshTimeout: 10000,
    // connectTimeout: 10000,
    // keepAlive: 10000,
    redisOptions: {
      password: "xxx",
      // reconnectOnError: function(err) {
      //   // Only reconnect when the error contains "READONLY"
      //   // `return 2` to resend failed command after reconnecting
      //   console.log(err)
      //   return err.message.includes('READONLY')
      // },
      // showFriendlyErrorStack: true,
      tls: {
        checkServerIdentity: (/*host, cert*/) => {
          // skip certificate hostname validation
          return undefined
        }
      },
    }
  })