I'm using the 4.3.3.Final in a jetty-based web-service implemented in kotlin. I have a singleton RedisCommand that I use for requests handling -- simple set/get/exists type of stuff. On the server side, we are not setting a timeout. If there is a lot of idle time (several minutes? 30 minutes?), the connection appears to go dead. Subsequent requests to redis fail, and the only fix appears to be a bounce of the server. Here's what the client-side connection code looks like:
private fun makeRedis(host: String, port: Int): RedisCommands<String, String> {
val redisClient: RedisClient = RedisClient.create(RedisURI.create(host, port))
redisClient.options = ClientOptions.builder().socketOptions(SocketOptions.builder()
.tcpNoDelay(true)
.keepAlive(true)
.connectTimeout(5L, TimeUnit.SECONDS)
.build())
.pingBeforeActivateConnection(true)
.build()
val redisConn: StatefulRedisConnection<String, String> = redisClient.connect()
redisConn.setTimeout(5L, TimeUnit.SECONDS)
val redisCommand = redisConn.sync()
authHealthChecks.register("redis commands", RedisCommandsHealthCheck(redisCommand))
return redisCommand
}