我们已经能够重现该问题,原因是Redis中的"timeout = 30"设置.
We have been able to reproduce the issue and the cause is "timeout=30" setting in Redis.
- 连接空闲30秒,Redis杀死该连接.
- 应用程序中的"Redis连接工厂"检测到损坏之前
连接,它将为读取或写入请求分配
- 代码
尝试使用此连接,但由于它已断开,因此无法
发送命令以进行读/写.因此,我们得到"JedisConnectionException:
流意外结束"异常
- Connection is idle for 30seconds and Redis kills the same.
- Before "Redis connection factory" in application detects the broken
connection, it gets allocation for read or write request
- Code
tries to use this connection but as it is broken, it is unable to
send command for read/write. Thus we get "JedisConnectionException:
Unexpected end of stream" exception
解决方案
- 将Redis超时设置为零
- 使用自定义JedisPoolConfig集
将minEvictableIdleTimeMillis设置为所需值.这将确保
空闲连接从Jedis连接池中释放
- set Redis timeout to Zero
- Using custom JedisPoolConfig set
the minEvictableIdleTimeMillis to desired value. This will ensure
idle connections are released from Jedis connection pool