scala-redis
scala-redis copied to clipboard
getting error java.lang.Exception: MOVED 2340 127.0.0.1:6301
Dear All,
i already used redis-cluster, but always get exception every put to redis-cluster
java.lang.Exception: MOVED 2340 10.2.15.40:6301
val nodes = Array( ClusterNode("node1", "127.0.0.1, 6301), ClusterNode("node2", "127.0.0.1", 6302) ) val r = new RedisCluster(new mutable.WrappedArray.ofRef(nodes): _*) { val keyTag = Some(RegexKeyTag) }
on other side, when use that cluster client
redis.processForKey (keyVal)(_.setex (keyVal, ttl, value))
redis-key is like
{key-1:123} {key-2:123}
can some help my issue ?
I tried this last week but I learned that RedisClient does support Redis Cluster yet.
Set up Redis cluster with master (30001, 30002, 30003) and slaves (30004, 30005, 30006) Connection test with native Redis-client succeed
import com.redis._
import java.net.{ServerSocket, Socket}
import java.io._
import collection.mutable.WrappedArray
val redislist = Array(("localhost", 30001), ("localhost", 30002), ("localhost", 30003))
val nodes = redislist.map { case (host, port) =>
cluster.ClusterNode(host+":"+port, host, port)
}
val r = new cluster.RedisCluster(new WrappedArray.ofRef(nodes): _*) {
val keyTag = Some(cluster.RegexKeyTag)
}
r.set("0", 0)
Will cause error
java.lang.Exception: MOVED 13907 127.0.0.1:30003
at com.redis.Reply$$anonfun$8.applyOrElse(RedisProtocol.scala:120)
at com.redis.Reply$$anonfun$8.applyOrElse(RedisProtocol.scala:119)
at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:36)
at com.redis.Reply$$anonfun$3.applyOrElse(RedisProtocol.scala:64)
at com.redis.Reply$$anonfun$3.applyOrElse(RedisProtocol.scala:64)
at scala.PartialFunction$OrElse.apply(PartialFunction.scala:167)
at com.redis.Reply$$anonfun$1.applyOrElse(RedisProtocol.scala:54)
at com.redis.Reply$$anonfun$1.applyOrElse(RedisProtocol.scala:54)
at scala.PartialFunction$OrElse.apply(PartialFunction.scala:167)
at com.redis.Reply$class.receive(RedisProtocol.scala:140)
at com.redis.RedisClient.receive(RedisClient.scala:95)
at com.redis.R$class.asBoolean(RedisProtocol.scala:253)
at com.redis.RedisClient.asBoolean(RedisClient.scala:95)
at com.redis.StringOperations$$anonfun$set$1.apply$mcZ$sp(StringOperations.scala:10)
at com.redis.StringOperations$$anonfun$set$1.apply(StringOperations.scala:10)
at com.redis.StringOperations$$anonfun$set$1.apply(StringOperations.scala:10)
at com.redis.Redis$class.send(RedisClient.scala:22)
at com.redis.RedisClient.send(RedisClient.scala:95)
at com.redis.StringOperations$class.set(StringOperations.scala:10)
at com.redis.RedisClient.set(RedisClient.scala:95)
at com.redis.cluster.RedisCluster$$anonfun$set$1.apply(RedisCluster.scala:181)
at com.redis.cluster.RedisCluster$$anonfun$set$1.apply(RedisCluster.scala:181)
at com.redis.cluster.RedisCluster$$anonfun$processForKey$1.apply(RedisCluster.scala:88)
at com.redis.cluster.RedisCluster$$anonfun$processForKey$1.apply(RedisCluster.scala:88)
at com.redis.RedisClientPool.withClient(Pool.scala:45)
at com.redis.cluster.RedisCluster.processForKey(RedisCluster.scala:88)
at com.redis.cluster.RedisCluster.set(RedisCluster.scala:181)
... 42 elided
Further investigation:
r.set("0", 0) => java.lang.Exception: MOVED 14039 127.0.0.1:30003
r.set("1", 1) => OK
r.set("2", 2) => OK
r.set("3", 3) => java.lang.Exception: MOVED 14039 127.0.0.1:30001
r.set("4", 4) => java.lang.Exception: MOVED 14039 127.0.0.1:30003
r.set("5", 5) => OK
r.set("6", 6) => OK
r.set("7", 7) => java.lang.Exception: MOVED 14039 127.0.0.1:30001
r.set("8", 8) => java.lang.Exception: MOVED 14039 127.0.0.1:30003
r.set("9", 9) => OK
Apparently there is a pattern in it. Not sure what's the problem yet.
Update: Issue probably caused by Redis configuration: #https://github.com/StackExchange/StackExchange.Redis/issues/179
Thanks for reporting .. will look into it over the weekend.
Any update here? I see this as well.
I did take a look but got swamped into other stuff. I will take a detailed look over the weekend. Sorry for not fixing it earlier ..
@Seyun is correct .. redisclient
doesn't support Redis Cluster as in https://redis.io/topics/cluster-spec .. The cluster that's implemented is something homegrown. I need to work on support for the native cluster. But currently I have no time and hence no promise on the timeline :-( .. However if anyone has a PR will gratefully accept it :-)
@debasishg Is there any update on this?
Unfortunately no :-( .. Too swamped into other stuff, lots of traveling as well. Let me try and spend some time during the Christmas holidays ..
Evaluating scala drivers for redis and get same error. Any plans to work on it?
i hava the same trobule , how can i solve it
Unfortunately I still have no bandwidth to work on this. Just curious has anyone been working on integrating redis cluster with redisclient
?
IMHO, just using redisclient
will be hard to integrate with Redis cluster.
A cluster connector is pretty much needed, like what Jedis had done here
My company ended up wrote a Scala port based on Jedis Cluster.
Unfortunately I still have no bandwidth to work on this. Just curious has anyone been working on integrating redis cluster with
redisclient
?
Will you add support in any time soon?