node.js - 无法连接到 redis 以与多个工作人员一起使用

标签 node.js redis

我在使用 heroku 中的 kue 连接到 redis 以处理多个工作进程时遇到问题。我可以与多个工作人员连接到本地主机上的 redis,但它似乎在与 redis-to-go 连接时中断。这似乎只有在我有多个 kue 工作人员/进程正在运行时才会中断。

kue.redis.createClient = function() {
  var client;
  client = redis.createClient(1234, 'tetra.redistogo.com');
  client.auth('xyz');
  return client;
};


jobs = kue.createQueue();
jobs.process("email, 2, function(job, done) {
  console.log("processing email");
  return done(null, null);
});

出现错误

Error: Uncaught, unspecified 'error' event.
    at RedisClient.emit (events.js:47:15)
    at Command.callback (/Users/transformer/Projects/Pictorious/Services/node_modules/redis/index.js:159:29)
    at RedisClient.return_error (/Users/transformer/Projects/Pictorious/Services/node_modules/redis/index.js:446:25)
    at RedisReplyParser. (/Users/transformer/Projects/Pictorious/Services/node_modules/redis/index.js:256:14)
    at RedisReplyParser.emit (events.js:64:17)
    at RedisReplyParser.send_error (/Users/transformer/Projects/Pictorious/Services/node_modules/redis/lib/parser/javascript.js:266:14)
    at RedisReplyParser.execute (/Users/transformer/Projects/Pictorious/Services/node_modules/redis/lib/parser/javascript.js:125:22)
    at RedisClient.on_data (/Users/transformer/Projects/Pictorious/Services/node_modules/redis/index.js:422:27)
    at Socket. (/Users/transformer/Projects/Pictorious/Services/node_modules/redis/index.js:66:14)
    at Socket.emit (events.js:64:17)

最佳答案

如果您使用的是 Redis To Go nano 实例(例如免费实例),您可能会遇到连接限制。你只允许 10 个连接,而且 kue 似乎在做 redis.client() 很多。所以,你可能会达到这个极限。

要确定,请在执行任何工作之前添加 redis.debug_mode = true; 并查看输出内容(注意:它会吐出很多信息,b\c发生了很多连接,但是在输出末尾或附近出现“最大连接数”错误。

至少当我们有一个工作人员和客户都访问 kue 时,我们似乎达到了这个限制。

希望这对您有所帮助。

关于node.js - 无法连接到 redis 以与多个工作人员一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8568943/

相关文章:

node.js - (Apollo) GraphQL 合并模式

redis - 存储非常大的数据列表

php - 将具有多个值的多个键设置到Redis

mongodb - 哪个 noSQL 数据库最适合大容量插入/写入?

java - 来自 Jedis 的 Redis sessionID

node.js - 使用 Node js通过tcp发送数据

javascript - ExpressJS - 在 router.get 中调用外部函数并呈现其数据

node.js - NodeJS 回调 : tracking db calls so I can terminate the process

javascript - 在 node.js 中异步处理多个返回

node.js - 在 redis/heroko/node.js 上捕获身份验证错误