Recently i work with redis and using jedis. In redis version 6, we can set required password mode for sentinels. I have 3 working sentinels, can connect and authen throught redis-cli. But using jedis, i can't connect to the sentinel with this warning:
Cannot get master address from sentinel running @ 127.0.0.1:26379. Reason: redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication required.. Trying next one.
Cannot get master address from sentinel running @ 127.0.0.1:36379. Reason: redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication required.. Trying next one.
Cannot get master address from sentinel running @ 127.0.0.1:16379. Reason: redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication required.. Trying next one.
And this error:
All sentinels down, cannot determine where is mymaster master is running...
Here is my code:
GenericObjectPoolConfig pc = new GenericObjectPoolConfig();
pc.setMinIdle(2);
pc.setMaxIdle(5);
pc.setMaxTotal(5);
JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, sentinels, pc, 1000*10, PASSWORD);
Jedis jedis = null;
try {
printer("Fetching connection from pool");
jedis = pool.getResource();
printer("Authenticating...");
jedis.auth(PASSWORD);
printer("auth complete...");
Socket socket = jedis.getClient().getSocket();
printer("Connected to " + socket.getRemoteSocketAddress());
printer("Writing...");
jedis.set("java-key-999", "java-value-999");
printer("Reading...");
printer(jedis.get("java-key-999"));
} catch (JedisException e) {
printer("Connection error of some sort!");
printer(e.getMessage());
Thread.sleep(2 * 1000);
} finally {
if (jedis != null) {
jedis.close();
}
}
Please help, thank you for your reading support <3