redis.clients.jedis.exceptions.JedisConnectionException: Unexpected end of stream.
nageswarao-pragada opened this issue · comments
I am getting the below error
below is the stack trace
ERROR 23-May-24 10:56:41,217 ConnectionFactory#79: Error while validating pooled Connection object.
redis.clients.jedis.exceptions.JedisConnectionException: Unexpected end of stream.
at redis.clients.jedis.util.RedisInputStream.ensureFill(RedisInputStream.java:248) ~[jedis-5.1.2.jar:?]
at redis.clients.jedis.util.RedisInputStream.readByte(RedisInputStream.java:47) ~[jedis-5.1.2.jar:?]
at redis.clients.jedis.Protocol.process(Protocol.java:136) ~[jedis-5.1.2.jar:?]
at redis.clients.jedis.Protocol.read(Protocol.java:222) ~[jedis-5.1.2.jar:?]
at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:350) ~[jedis-5.1.2.jar:?]
at redis.clients.jedis.Connection.getStatusCodeReply(Connection.java:268) ~[jedis-5.1.2.jar:?]
at redis.clients.jedis.Connection.ping(Connection.java:511) ~[jedis-5.1.2.jar:?]
at redis.clients.jedis.ConnectionFactory.validateObject(ConnectionFactory.java:77) [jedis-5.1.2.jar:?]
at org.apache.commons.pool2.impl.GenericObjectPool.evict(GenericObjectPool.java:748) [commons-pool2-2.12.0.jar:2.12.0]
at org.apache.commons.pool2.impl.BaseGenericObjectPool$Evictor.run(BaseGenericObjectPool.java:162) [commons-pool2-2.12.0.jar:2.12.0]
at org.apache.commons.pool2.impl.EvictionTimer$WeakRunner.run(EvictionTimer.java:115) [commons-pool2-2.12.0.jar:2.12.0]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:?]
at java.util.concurrent.FutureTask.runAndReset(Unknown Source) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:?]
at java.lang.Thread.run(Unknown Source) [?:?]
Jedis Configuration snippet is
private void initRedisConnection() {
try {
LOG.info("Trying to initiate redis connection.");
var redisHostName = System.getenv("REDIS_HOST");
var redisPort = null != System.getenv("REDIS_PORT") ? Integer.parseInt(System.getenv("REDIS_PORT")) : 6379;
var redisUserName = System.getenv("REDIS_USERNAME");
var redisPassword = System.getenv("REDIS_PASSWORD");
var maxTotal = Integer.parseInt(GatewayConfiguration.getInstance().getProperty("redis.connection.pool.maxTotal", "2000"));
var maxIdle = Integer.parseInt(Test.getInstance().getProperty("redis.connection.pool.maxIdle","300"));
var minIdle = Integer.parseInt(Test.getInstance().getProperty("redis.connection.pool.minIdle","100"));
var timeout = Integer.parseInt(GatewayConfiguration.getInstance().getProperty("redis.connection.pool.timeout","60000"));
ConnectionPoolConfig poolConfig = new ConnectionPoolConfig();
poolConfig.setMaxTotal(maxTotal);
poolConfig.setMaxIdle(maxIdle);
poolConfig.setMinIdle(minIdle);
LOG.debug("Pool configuration : {}",poolConfig.toString());
jedis = new JedisPooled(poolConfig,redisHostName, redisPort, timeout, redisUserName, redisPassword);
LOG.info("Successfully initiated redis connection.");
} catch(Exception e) {
LOG.error("Failed to initialize redis connection. Error : {} {}", e.getMessage(), e);
}
}
Jedis version: 5.1.2
commons-pool2 2.12.0
Java version: java11
Please suggest
As it is described so far, I don't see anything to be concerned about.
It could be as simple as an idle connection being disconnected from server side.
@sazzad16
How can i avoid this problem
How can i avoid this problem
- Check the
timeout
parameter in your Redis server and set it never to kill client connection - Maintain a perfect network
Closing this issue as it seems out of scope from Jedis. Moreover, we don't expect most users to maintain above suggestions and keep our settings as such.
@nageswarao-pragada These are logs usually without harming your application. You can also consider using upcoming 5.2.0 release (5.2.0-SNAPSHOT for now) which lowered the log level. So you won't see the logs depending on your logging configuration.
Here is how to use Jedis snapshot releases.