jedis icon indicating copy to clipboard operation
jedis copied to clipboard

NOAUTH Authentication required

Open Fejm opened this issue 1 year ago • 2 comments

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

  1. Create pool
  2. Use it, wait some time
  3. 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)

Fejm avatar Jul 13 '22 09:07 Fejm

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.

sazzad16 avatar Jul 13 '22 12:07 sazzad16

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)

Fejm avatar Jul 13 '22 12:07 Fejm

I am also using Jedis (version 4.3.1) and getting these exceptions after a while

literally1984 avatar Nov 10 '22 01:11 literally1984

I set up a connection to my Redis database using the following code:

JedisPool pool = new JedisPool("myredisdb.com", 37716, "default", "supersecretpassword");

literally1984 avatar Nov 10 '22 01:11 literally1984

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]

sazzad16 avatar Dec 12 '22 10:12 sazzad16