无法连接到 redis 以与多个 worker kues 一起使用 [英] trouble connecting to redis to go with with multiple worker kues

查看:42
本文介绍了无法连接到 redis 以与多个 worker kues 一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm having trouble connecting to redis to go with multiple worker processes using kue in heroku. I can connect with multiple workers to redis on localhost but it seems to break on connecting with redis-to-go. This only seems to break when I have multiple kue workers/processes running.

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() 很多.所以,你可能会达到这个限制.

If you're using Redis To Go nano instance (e.g. the free one) you may be running into a connection limit. You are only allowed 10 connections and it seems that kue is doing redis.client() a lot. So, you could be hitting that limit.

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

To find out for sure, add redis.debug_mode = true; before you do any work and see what the output says (note: it's going to spit out a lot of info, b\c there are a lot of connections happening, however "max connections" error at or near the end of the output.

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

At least we seem to be hitting this limit when we have a worker and client both accessing kue.

希望这会有所帮助.

这篇关于无法连接到 redis 以与多个 worker kues 一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆