3

Am trying to connect to AWS redis elastic cache, but i keep getting this error all the time. I am not sure what i am doing wrong here, any help is greatly appreciated. Here's my code

 async function testRedis(){
try{
 const asyncRedis = require("async-redis");
        const client = asyncRedis.createClient({
            port: 6379,
            host: 'myHost',
            auth_pass: redisPassword,
            connect_timeout: 900,
            enable_offline_queue: false
        })
        const response = await client.set("test", "response");
        const redisResp = await client.get("test");
        const connStatus = client.quit()
        console.log('connection status::', connStatus)
    } catch (err) {
        console.log(err)
    }
}
user3172208
  • 91
  • 1
  • 5
  • "errorType": "AbortError", "errorMessage": "Redis connection in broken state: connection timeout exceeded. It might have been processed.", "code": "CONNECTION_BROKEN", "command": "AUTH", – user3172208 Sep 03 '20 at 15:12

1 Answers1

1

I had the same issue. My host didn't an provide IP address for host option so I fixed it by using a connection string: [redis[s]:]//[[user][:password@]][host][:port][/db-number][?db=db-number[&password=bar[&option=value]]]

Should look something like:

const connectionString = 'rediss://username:password@url-to-your.redis.db.server.com:2500'
const client = asyncRedis.createClient(connectionString);

Async redis is a wrapper over Node Redis: https://www.npmjs.com/package/redis Check out the docs for more info.

Phillip Havea
  • 243
  • 2
  • 7