Yacine BENABDESSELAM
Yacine BENABDESSELAM

Reputation: 23

Error when trying to connect to sentinel with password using ioredis nodejs module

I am trying to use ioredis to connect to my sentinel service under docker which require a password in my config. Here is my code :

sentinels: [
{ host: "192.168.0.35", port: 26379 }
],
name: "redismaster",
sentinelPassword: "sentinelPassword",
sentinelRetryStrategy: function(times) {
// reconnect after
return Math.max(times * 100, 3000);
}
});

But it doesn't succeed. Here is the log when activate DEBUG=ioredis :

2020-02-07T18:06:10.091Z ioredis:redis status[192.168.0.35:26379]: [empty] -> connecting
2020-02-07T18:06:10.093Z ioredis:redis queue command[192.168.0.35:26379]: 0 -> sentinel([ 'get-master-addr-by-name', 'redismaster' ])
2020-02-07T18:06:10.096Z ioredis:redis status[192.168.0.35:26379]: connecting -> connect
2020-02-07T18:06:10.097Z ioredis:redis write command[192.168.0.35:26379]: 0 -> auth([ 'thisis1SentinElP@sSwOrd' ])
2020-02-07T18:06:10.097Z ioredis:redis status[192.168.0.35:26379]: connect -> ready
2020-02-07T18:06:10.097Z ioredis:connection send 1 commands in offline queue
2020-02-07T18:06:10.098Z ioredis:redis write command[192.168.0.35:26379]: 0 -> sentinel([ 'get-master-addr-by-name', 'redismaster' ])
2020-02-07T18:06:10.100Z ioredis:redis write command[192.168.0.35:26379]: 0 -> sentinel([ 'sentinels', 'redismaster' ])
2020-02-07T18:06:10.101Z ioredis:SentinelConnector Updated internal sentinels: [{"host":"192.168.0.35","port":26379}] @1
2020-02-07T18:06:10.102Z ioredis:SentinelConnector resolved: 192.168.0.23:6379
2020-02-07T18:06:10.105Z ioredis:redis status[192.168.0.23:6379]: connecting -> connect
2020-02-07T18:06:10.106Z ioredis:redis write command[192.168.0.23:6379]: 0 -> info([])
Redis connected
2020-02-07T18:06:10.106Z ioredis:redis status[192.168.0.35:26379]: ready -> close
2020-02-07T18:06:10.106Z ioredis:connection skip reconnecting since the connection is manually closed.
2020-02-07T18:06:10.106Z ioredis:redis status[192.168.0.35:26379]: close -> end
Redis error in (/config/redis.js) ReplyError: NOAUTH Authentication required.

According to the logs, i see that my redis client can connect to sentinel, it also find the real redis server under sentinel mode and select the database. I get the log that redis is connected, but after that, the connection is closed. Where am i missing ?

PS: i did add also the config snetinel-annouce-ip in case my redis client doesn't recognize the ip of sentinel, but in the logs, it got the good private ip : 192.168.0.35.

thanks for your help.

Upvotes: 2

Views: 7593

Answers (1)

Phong Tat
Phong Tat

Reputation: 86

try to set password to both password and sentinelPassword

{ 
  sentinels: [
    { host: "192.168.0.35", port: 26379 }
  ],
  name: "redismaster",
  password: "yourpassword",
  sentinelPassword: "yourpassword"
}

Upvotes: 7

Related Questions