redis.clients.jedis.exceptions.JedisConnectionException: Unexpected end of stream.
at redis.clients.jedis.util.RedisInputStream.ensureFill(RedisInputStream.java:202)
at redis.clients.jedis.util.RedisInputStream.readByte(RedisInputStream.java:43)
at redis.clients.jedis.Protocol.process(Protocol.java:155)
at redis.clients.jedis.Protocol.read(Protocol.java:220)
at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:283)
at redis.clients.jedis.Connection.getIntegerReply(Connection.java:225)
at io.rebloom.client.Client.add(Client.java:122)
I searched for possible root causes and find out that:
1) Connection is idle for a long time and therefore disconnected by the server
2) Jedis instance is operated concurrently by multiple threads
Ad 1) There is no timeout configured on my Redis server
> config get timeout
"timeout"
"0"
Ad 2) I use JedisPool (100 connections in the pool) in my Jedis client which,
as I read, should be thread safe.
Here is the snippet of my code:
class XYZ()
{
private var conn: Client = _
...
private def configureJedisPool(): JedisPool = {
val timeoutMs = 30000 // 30s
val poolSize = 100
val conf = new JedisPoolConfig()
conf.setMaxTotal(poolSize)
conf.setTestOnBorrow(false)
conf.setTestOnReturn(false)
conf.setTestOnCreate(false)
conf.setTestWhileIdle(true)
conf.setMinEvictableIdleTimeMillis(30000)
conf.setTimeBetweenEvictionRunsMillis(15000)
conf.setNumTestsPerEvictionRun(-1)
conf.setFairness(true)
new JedisPool(conf, hostname, port, timeoutMs)
}
def open(): Unit = {
// Create connection to Redis DB
val pool = configureJedisPool()
conn = new Client(pool)
}
def seen(element: ABC): Boolean = {
!
conn.add(filterName, MLRowKeySerializer.
serialize(element))
}
...
Any help would by appreciated. Thanks a lot.