简体   繁体   中英

Connecting to redis using kue always creates a connection to localhost

I can't connect to Redis using kue, I've followed this article , practically I'm creating the connection by using the kue redis client, and the connection code is this:

  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;
   };

and it seems like Kue is trying to connect to a local Redis (which I don't have installed), because I'm getting this exception:

Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED

I've read this post and it seems like the issue has been resolved in version 0.8 and I'm using 0.8.11 :/, finally I also wanted to override the client using a different client instance by using redis nodejs without any luck, because I'm getting the same error.

any help will be more than appreciated. thanks!

I used a different way to setup the connection and it works so far this is what I've done:

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;
        }
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM