我无法使用kue连接到Redis,我已经按照这个
article,几乎我正在使用kue redis客户端创建连接,连接代码是这样的:
var kue = require('kue'),redis = require('kue/node_modules/redis'); app.redisClient = redis.createClient('6379','remoteip',{}); app.redisClient.on('error',function (err) { console.log('Redis error encountered',err); }); app.redisClient.on('end',function() { console.log('Redis connection closed'); }); kue.redis.createClient = function() { console.log('client ------------------',app.redisClient); return app.redisClient; };
似乎Kue正在尝试连接到本地Redis(我没有安装),因为我遇到了这个异常:
Error: Redis connection to 127.0.0.1:6379 Failed – connect
ECONNREFUSED
我已经阅读了这个post,看起来这个问题已经在0.8版本中解决了,而且我使用的是0.8.11:/,最后我还想使用redis nodejs使用不同的客户端实例来覆盖客户端而没有任何运气,因为我收到同样的错误.
任何帮助将不仅仅是赞赏.
谢谢!
解决方法
我使用了一种不同的方式来设置连接,它到目前为止这是我所做的:
app.redisClient = redis.createClient(config.redisPort,config.redisUrl,{}); app.redisClient.on('connect',function () { console.info('successful connection to redis server'); }); app.redisClient.on('error',function (err) { console.log('Redis error encountered',err); }); app.redisClient.on('end',function() { console.log('Redis connection closed'); }); kue.app.listen(config.kuePort); app.jobs = kue.createQueue({ redis: { createClientFactory: function(){ return app.redisClient; } } });