Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
afernandezod opened this issue Oct 25, 2021 · 9 comments

Comments

@afernandezod
Copy link

afernandezod commented Oct 25, 2021

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.

@wellle
Copy link
Owner

wellle commented Oct 28, 2021

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!

@afernandezod
Copy link
Author

@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!!!!!!!

@wellle
Copy link
Owner

wellle commented Oct 28, 2021

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

@si3nloong
Copy link
Contributor

si3nloong commented Nov 3, 2021

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

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

@afernandezod
Copy link
Author

@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.

@QuanTran91
Copy link

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

@wellle
Copy link
Owner

wellle commented Nov 21, 2022

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? 🙏
#128

@wellle
Copy link
Owner

wellle commented Jan 17, 2024

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

@wellle wellle closed this as completed Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants