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

MOVED error in Redis Storage config & Elasticache #129

Open
danDanV1 opened this issue Apr 29, 2018 · 6 comments
Open

MOVED error in Redis Storage config & Elasticache #129

danDanV1 opened this issue Apr 29, 2018 · 6 comments

Comments

@danDanV1
Copy link

Is lua-resty-auto-ssl compatible with aws redis elasticache?

It's all working fine with local storage, trying to trouble shoot getting a redis elasticache cluster working. Connecting with the cluster Configuration Endpoint.

        auto_ssl:set("redis", {
          host = "clustercfg.d1rp7blahblah.vqmcgo.use1.cache.amazonaws.com",
          port = 6379
        })
2018/04/29 04:28:56 [error] 23176#23176: *20 [lua] ssl_certificate.lua:134: get_cert_der(): auto-ssl: error fetching certificate from storage for www.domain.me: MOVED 15012 10.13.41.79:6379, context: ssl_certificate_by_lua*, client: 10.33.22.89, server: 0.0.0.0:4431
2018/04/29 04:28:56 [error] 23176#23176: *7 [lua] ssl_certificate.lua:134: get_cert_der(): auto-ssl: error fetching certificate from storage for www.domain.me: MOVED 15012 10.13.41.79:6379, context: ssl_certificate_by_lua*, client: 10.13.22.89, server: 0.0.0.0:4431
2018/04/29 04:28:56 [error] 23176#23176: *20 [lua] ssl_certificate.lua:77: issue_cert(): auto-ssl: failed to obtain lock: MOVED 10592 10.33.41.79:6379, context: ssl_certificate_by_lua*, client: 10.13.22.89, server: 0.0.0.0:4431
@danDanV1
Copy link
Author

$ redis-cli -h blahblah.clustercfg.use1.cache.amazonaws.com -p 6379
blahblah.clustercfg.use1.cache.amazonaws.com:6379> SET foo 100
(error) MOVED 16008 10.13.01.79:6379
blahblah.clustercfg.use1.cache.amazonaws.com:6379> GET foo
(error) MOVED 16008 10.13.01.79:6379

Using the -c param on redis-cli command line client sorts it out. It follows the MOVED redirect from the cluster.

$ redis-cli -h blahblah.clustercfg.use1.cache.amazonaws.com -p 6379 -c
blahblah.clustercfg.use1.cache.amazonaws.com:6379> SET foo 200
-> Redirected to slot [12182] located at 10.33.41.79:6379
OK
10.13.01.79:6379> GET foo
"200"
10.13.01.79:6379>

Can we configure resty-auto-ssl to connect with "-c"? or perhaps detect the MOVED response and reconnect to the appropriate server?

@marcfowler
Copy link

marcfowler commented May 1, 2018

Did you have any luck resolving this? I wasn't even able to connect using a direct shard endpoint (blahblah-001.xyz.0001.use1.cache.amazonaws.com). I don't have much experience with Redis and not entirely sure how to resolve this!

Edit: Looking back over, I assume this is because Elasticache is a Redis cluster and #39 confirms this isn't supported, though openresty/lua-resty-redis#102 (comment) points to a client that does handle it so perhaps that could be used instead?

Is there a way to use Redis without a cluster in AWS without manually running it via EC2 in the interim?

@danDanV1
Copy link
Author

danDanV1 commented May 2, 2018

I'm looking into using this storage adapter: https://github.com/steve0511/resty-redis-cluster

Would be great if lua-resty-auto-ssl supported it natively.

Another quick solution is connecting directly to the node that is the primary read/write. Could do some hackish work arounds to detect which one it is and keep it up-to-date. Might be able to handle the MOVED response directly in the lua scripts with the current adapter?? I think using the redis-cluster adapter is more elegant. However, I'm in a bit of the same boat, no experience programming in Lua.

@jordanade
Copy link

I wonder if a solution has been found for this problem, or a workaround configuration for elasticache? Will it work if I create a Redis store with Number of replicas=0?

Or...what's the best workaround that avoids Redis entirely? Shared EFS or EBS mount?

@alexphelps
Copy link

Any updates on this? I've stumbled into the issue of needing a way to support a redis cluster storage backend as well.

@alexphelps
Copy link

I was able to adapt the existing redis storage adapter to work with resty-redis-cluster. Seems to work on my local, haven't used it out in the wild or with aws elasticache redis clusters yet.

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