JedisConnectionException: Unexpected end of stream error

Radhika Satish picture Radhika Satish · Jun 7, 2017 · Viewed 10.7k times · Source

I am trying to perform rpush operation and encountered the following error:

redis.clients.jedis.exceptions.JedisConnectionException: Unexpected end of stream.
    at redis.clients.util.RedisInputStream.ensureFill(RedisInputStream.java:199) ~[jedis-2.9.0.jar:na]
    at redis.clients.util.RedisInputStream.readByte(RedisInputStream.java:40) ~[jedis-2.9.0.jar:na]
    at redis.clients.jedis.Protocol.process(Protocol.java:151) ~[jedis-2.9.0.jar:na]
    at redis.clients.jedis.Protocol.read(Protocol.java:215) ~[jedis-2.9.0.jar:na]
    at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:340) ~[jedis-2.9.0.jar:na]
    at redis.clients.jedis.Connection.getIntegerReply(Connection.java:265) ~[jedis-2.9.0.jar:na]
    at redis.clients.jedis.Jedis.rpush(Jedis.java:865) ~[jedis-2.9.0.jar:na]
    at

Any idea to resolve this error?

Answer

Golden Man picture Golden Man · Mar 22, 2019

the cause is that server setting up timeout nonzero, it means after one period connection is disposed or closed. So client takes the connection from pool, but after that time it is invalid!

Solution is: Set timeout on server to 0 or Do not keep pool on client -> GenericObjectPoolConfig.setMaxIdle(0) So each time to connect server, client take a new connection instead old one from pool