1

I am trying to delete keys of a specific pattern from redis server but while executing it, it shows:

redis.clients.jedis.exceptions.JedisConnectionException: Unexpected end of stream.
    at redis.clients.util.RedisInputStream.ensureFill(RedisInputStream.java:199)
    at redis.clients.util.RedisInputStream.readByte(RedisInputStream.java:40)
    at redis.clients.jedis.Protocol.process(Protocol.java:153)
    at redis.clients.jedis.Protocol.read(Protocol.java:218)
    at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:341)
    at redis.clients.jedis.Connection.getBinaryMultiBulkReply(Connection.java:277)
    at redis.clients.jedis.Jedis.keys(Jedis.java:284)

For your reference, my server timeout value is 0 and jedis version which I have been using is 2.10.2. Following is the code snippet which I am trying to execute:

try {
    Set<String> keys = jedis.keys(pattern);
    jedis.del(keys.toArray(new String[keys.size()]));
} catch(Exception e) {
    log.error("Failed to delete key entry for pattern {0}", pattern);
    throw e;
}

here pattern is the string we are trying to delete.

Any suggestion to resolve the error?

=================================================================

UPDATE-1:

  1. The code is running fine in local, no issues with any jedis function.
  2. When running on remote server, other functions are getting executed correctly except this delete keys method. Precisely while executing jedis.keys()
Chanfool21
  • 57
  • 9

0 Answers0