forked from acrosa/scala-redis
-
Notifications
You must be signed in to change notification settings - Fork 219
Open
Description
If a redis server restarts, the client connection is not initialized.
When the redis server restarts, the socket connection between the server and the client is lost. So the value of 'connected' in the following code gets to be false, which lets 'connect' method invoked.
https://github.com/debasishg/scala-redis/blob/master/src/main/scala/com/redis/IO.scala#L68
The problem is that 'connect' does not invoke 'initialize' method in it compared to 'reconnect'.
In my case, this makes problems such as
- 'auth' is not invoked because 'initialize' is not invoked
- the overridden 'reconnect' is not invoked, which is for re-subscribing channels when reconnected.
FYI, the following is an inherited class from RedisClient for taking a function of 'onReconnect'
class ResilientRedisClient(override val host: String, override val port: Int,
override val database: Int = 0, override val secret: Option[Any] = None, override val timeout : Int = 0)
(onReconnect:RedisClient => Any) extends RedisClient {
override def reconnect: Boolean = {
val result = super.reconnect
if (result) onReconnect(this)
result
}
}
Metadata
Metadata
Assignees
Labels
No labels