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
ERR MOVED with ioredis 5.3.1 when connected to ElastiCache Serverless #1865
Comments
I'm having the same problem with ioredis 5.3.2:
I believe it's because every 11 days or so, AWS Serverless closes the underlying connection (resulting in I ran with debug logs enabled and got this:
Errors after this point look like: {
"name": "ReplyError",
"message": "ERR MOVED 7351 <REDACTED>.serverless.use2.cache.amazonaws.com:6379",
"stack": [
"parseError (node_modules/.pnpm/redis-parser@3.0.0/node_modules/redis-parser/lib/parser.js:179:12)",
"parseType (node_modules/.pnpm/redis-parser@3.0.0/node_modules/redis-parser/lib/parser.js:302:14)"
]
} Due to:
Minimum Reproducible Issueimport http from "http";
import net from "net";
import { parse } from "url";
import { getRedisClient } from "your-redis-client-constructor-here";
const hostname = "127.0.0.1";
const port = 4020;
// Needs to be Redis.Cluster
const redisClient = getRedisClient();
const econnresetAllNodes = (clusterClient) => {
const allNodes = Object.values(clusterClient.connectionPool.nodes.all);
for (const node of allNodes) {
if (!node.stream) continue;
// Even though it's named "stream", it's actually a NodeJS socket
node.stream.destroy();
}
};
const server = http.createServer((req, res) => {
const url = parse(req.url, true);
if (req.method === "PUT" && url.pathname === "/connreset") {
req.on("data", (chunk) => {});
req.on("end", () => {
econnresetAllNodes(redisClient);
res.statusCode = 200;
res.setHeader("Content-Type", "text/plain");
res.end("Connection reset successfully\n");
});
} else {
res.statusCode = 404;
res.end("Not Found\n");
}
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
}); Then after
Initial Connection Logs (if helpful)
|
On further investigation, we decided to move to node-redis; it seems like this project is now in maintenance mode. |
@adamshugar Thanks for the comment, having a similar problem and came to the same conclusion. Wondering if you'd be willing to post your working node-redis client config for serverless elasticache in this thread. |
Occasionally the following error is reported:
When the app container is restarted (and a new Redis.Cluster client instance is created) the problem does not occur anymore.
The client is created as follows:
I added the
retryDelayOnMoved
setting after this was reported for the first time but this does not seem to have effect.Can this be an issue of the ioredis client? The message
ERRO MOVED 7572 url:post
seems completely valid - see Redis docs section Moved Redirection.Can this be related to this note: Aws Elasticache Clusters with TLS.
Any help is welcome. This issue is hard for us to debug since we are not able to reproduce it.
The text was updated successfully, but these errors were encountered: