node.js – 使用kue连接到redis始终会创建与localhost的连接

我无法使用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;
        }
    }
});

相关文章

这篇文章主要介绍“基于nodejs的ssh2怎么实现自动化部署”的...
本文小编为大家详细介绍“nodejs怎么实现目录不存在自动创建...
这篇“如何把nodejs数据传到前端”文章的知识点大部分人都不...
本文小编为大家详细介绍“nodejs如何实现定时删除文件”,内...
这篇文章主要讲解了“nodejs安装模块卡住不动怎么解决”,文...
今天小编给大家分享一下如何检测nodejs有没有安装成功的相关...