rmq icon indicating copy to clipboard operation
rmq copied to clipboard

Trying to use rmq against a clustered Redis/Elasticcache Db. keep getting the "MOVED" error.

Open afernandezod opened this issue 4 years ago • 6 comments

After reading the "MOVED" error is due to instantiate a client to a clustered redis Db, I tried several options using redis.NewClusterCLienat, redis.NewClient and when ready to establish the connection I tried rmq.OpenConnectionWithRedisClient in order to once having the connection active be able to open the queue (rmq-connection.OpenQueue().

Not sure if I am missing something or clustered redis Db are not in the scope for rmq.

Any help is greatly appreciated.

Here part of the code:

func redisConnect(quename string) rmq.Queue {
	redisClient := redis.NewClient(&redis.Options{
		Addr: Host,
		DB:   0,
	})

	nodes := strings.Split(Hosts, ",")
	c := redis.NewClusterClient(&redis.ClusterOptions{
		Addrs: nodes,
		NewClient: func(opt *redis.Options) *redis.Client {
			opt.Addr = Host
			opt.DB = 0
			return redis.NewClient(opt)
		},
	})

	ctx := context.Background()
	pingError := c.Ping(ctx).Err()

	if c.Ping(ctx).Err() != nil {
		panic("Unable to connect to redis ")
	}

	connection, err := rmq.OpenConnectionWithRedisClient("TCP", redisClient, nil)
	if err != nil {
		panic(err)
	}

	coolqueue, err := connection.OpenQueue(quename)
	if err != nil {
		panic(err)
	}

	return coolqueue
}

Thanks.

afernandezod avatar Oct 25 '21 22:10 afernandezod

Hey, thanks for opening this issue. Unfortunately I have not been exposed to clustered Redis yet. And I don't think I will be able to set it up for testing anytime soon.

But can you add some more details as to where exactly you are seeing this error? Like in which operation is it being triggered? Thanks!

wellle avatar Oct 28 '21 14:10 wellle

@wellle I appreciate your response. I already trying to create a new version of the Redis Db but not clustered to try again.

Basically the "MOVED...." error occurs during any of the rmq.open... .methods:

connection, err := rmq.OpenConnection("producer", "tcp", Host, 0, nil) or connection, err := rmq.OpenConnectionWithRmqRedisClient("producer", redisClient, nil) or connection, err := rmq.OpenConnectionWithRedisClient("producer", redisClient, nil)

Obviously when RedisClient is needed I instantiate one: redisClient := redis.NewClient(&redis.Options{ Addr: Host, DB: 0, MaxRetries: 0, MinRetryBackoff: 0, MaxRetryBackoff: 0, DialTimeout: 0, ReadTimeout: 0, WriteTimeout: 0, PoolFIFO: false, PoolSize: 0, MinIdleConns: 0, MaxConnAge: 0, PoolTimeout: 0, IdleTimeout: 0, IdleCheckFrequency: 0, Limiter: nil, })

Hope this helps and will pay attention when clustered Db are available.

Thanks!!!!!!!

afernandezod avatar Oct 28 '21 15:10 afernandezod

Thanks. Can you also show the full Redis error you are seeing? (please obfuscate any sensitive details if present)

wellle avatar Oct 28 '21 15:10 wellle

The error has the following format:

MOVED <moved node's IP:port> (MOVED 7652 10.0.4.210:6379)

Here some of the links I read:

https://stackoverflow.com/questions/64374113/replyerror-moved-error-after-connecting-to-redis-cluster-aws

https://stackoverflow.com/questions/48232539/aws-redis-cluster-move-error

https://serverfault.com/questions/812156/redis-cluster-error-moved

https://aws.amazon.com/premiumsupport/knowledge-center/elasticache-redis-client-readonly/

afernandezod avatar Oct 28 '21 15:10 afernandezod

I think it was your setup issue, try to amend your config as below

redis.NewClusterClient(&redis.ClusterOptions{ Addrs: nodes, })

si3nloong avatar Nov 03 '21 03:11 si3nloong

@si3nloong Thanks. I tried that also and same results. I think as @wellle mentioned rmq hasn't been exposed to this flavor of clusters. As soon cloud/AWS team changed the condition from clustered to non-clustered, it worked.

afernandezod avatar Nov 03 '21 12:11 afernandezod

So the rmq doest not support Redis in cluster mode? Do they?

QuanTran91 avatar Nov 21 '22 08:11 QuanTran91

Here's a related PR which is fairly close to complete. Maybe there's someone who could pick up this work and address the review comments so it can get merged? 🙏 https://github.com/adjust/rmq/pull/128

wellle avatar Nov 21 '22 12:11 wellle

Again I'm not sure if this is still a problem. Closing for now. Please reopen if the problem still persists :v:

wellle avatar Jan 17 '24 17:01 wellle