jedis
jedis copied to clipboard
NOAUTH Authentication required
I'm using same code on 4.x and 3.x, while on 3.x it's working without any issue then on 4.x it's throwing exceptions
Just create pool:
final JedisPoolConfig poolConfig = new JedisPoolConfig();
poolConfig.setMaxTotal(16);
poolConfig.setMaxIdle(4);
poolConfig.setTestWhileIdle(true);
if (poolConfig.getMinIdle() < 1)
{
poolConfig.setMinIdle(2);
}
JedisPool pool = new JedisPool(poolConfig, AppConfig.redisHost, AppConfig.redisPort, AppConfig.redisTimeout, AppConfig.redisPass);
Then, after some time, while using my app i got those errors:
redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication required.
11:24:06 [WARN]: at redis.clients.jedis.Protocol.processError(Protocol.java:96)
11:24:06 [WARN]: at redis.clients.jedis.Protocol.process(Protocol.java:137)
11:24:06 [WARN]: at redis.clients.jedis.Protocol.read(Protocol.java:192)
11:24:06 [WARN]: at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:316)
11:24:06 [WARN]: at redis.clients.jedis.Connection.getOne(Connection.java:298)
11:24:06 [WARN]: at redis.clients.jedis.Connection.executeCommand(Connection.java:123)
11:24:06 [WARN]: at redis.clients.jedis.Jedis.zrevrange(Jedis.java:6522)
11:24:06 [WARN]: at (***).LocalRanking$1.run(LocalRanking.java:68)
(..)
11:24:26 [ERROR]: [redis.clients.jedis.JedisFactory] Error while validating pooled Jedis object.
redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication required.
at redis.clients.jedis.Protocol.processError(Protocol.java:96) ~[?:?]
at redis.clients.jedis.Protocol.process(Protocol.java:137) ~[?:?]
at redis.clients.jedis.Protocol.read(Protocol.java:192) ~[?:?]
at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:316) ~[?:?]
at redis.clients.jedis.Connection.getStatusCodeReply(Connection.java:243) ~[?:?]
at redis.clients.jedis.Jedis.ping(Jedis.java:356) ~[?:?]
at redis.clients.jedis.JedisFactory.validateObject(JedisFactory.java:211) ~[?:?]
at org.apache.commons.pool2.impl.GenericObjectPool.evict(GenericObjectPool.java:745) ~[?:?]
at org.apache.commons.pool2.impl.BaseGenericObjectPool$Evictor.run(BaseGenericObjectPool.java:160) ~[?:?]
at org.apache.commons.pool2.impl.EvictionTimer$WeakRunner.run(EvictionTimer.java:113) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) ~[?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Expected behavior
No exception thrown
Actual behavior
NOAUTH Authentication required DataException is thrown after some time
Steps to reproduce:
Please create a reproducible case of your problem. Make sure that case repeats consistently and it's not random
- Create pool
- Use it, wait some time
- Exception thrown
Redis / Jedis Configuration
(see code example)
Jedis version:
4.2.3
Redis version:
6.0.3 / 7.0.3 (tested both)
Java version:
JAVA 17 (17.0.3.1+2-LTS-6)
on 4.x it's throwing exceptions
To be precise, it's not throwing exceptions; it's logging exceptions.
on 3.x it's working without any issue
Which Jedis 3.x version are you testing with? I'm assuming it's older that Jedis 3.6.0.
Which Jedis 3.x version are you testing with? I'm assuming it's older that Jedis 3.6.0.
Currently on 3.9.0 as quick fix, but for about year it was working fine with 3.6.3 and then 3.7.1 (and it's still working on old app)
I am also using Jedis (version 4.3.1) and getting these exceptions after a while
I set up a connection to my Redis database using the following code:
JedisPool pool = new JedisPool("myredisdb.com", 37716, "default", "supersecretpassword");
It seems similar to this stackoverflow question: Intermittent 'NOAUTH Authentication Required' error while using Jedis.
Please check if the answer is applicable for you as well. I am including the answer below:
[answer]
One of the possibilities is that the underlying socket of the Jedis
object was actually closed and so its AUTHed state is cleared. This may happen if the Jedis
object borrowed from JedisPool
is closed twice (or multiple times). Because first close()
would return the object to the pool but subsequent close()
would cause the underlying socket object to be closed.
Check of the Jedis
object borrowed from JedisPool
is closed multiple times. If you use try-with-resources, one close operation could be hidden, e.g.
try (Jedis jedis = this.pool.getResource()) {
// operations by jedis
jedis.close(); // <-- first, visible close
} // <-- second, hidden close
[/answer]