2

I'm passing these configurations to my queue:

module.exports = {
    host: 'xxxxx-cluster.abnjj1.ng.0001.use1.cache.amazonaws.com',
    port: 6379
}

And creating the kue:

const kue = require('kue')
const MailJob = require('../app/jobs/MailJob.js')
const redisConfig = require('../config/redis')
const jobs = [MailJob]

class Queue {
    constructor(){
        this.kue = kue.createQueue(redisConfig)

        this.processQueue()
    }

    processQueue(){
        return jobs.forEach(job => this.kue.process(job.key, job.handle))
    }
}

module.exports = new Queue()

But it's returning always the same error related to connection with localhost. That's not make sense because i'm passing the host of elasticache

Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1126:14)
Emitted 'error' event on Queue instance at:
    at RedisClient.<anonymous> (/home/laurabeatris/Área de trabalho/personal projects/kue-test/node_modules/kue/lib/redis.js:65:13)
    at RedisClient.emit (events.js:209:13)
    at RedisClient.on_error (/home/laurabeatris/Área de trabalho/personal projects/kue-test/node_modules/kue/node_modules/redis/index.js:401:14)
    at Socket.<anonymous> (/home/laurabeatris/Área de trabalho/personal projects/kue-test/node_modules/kue/node_modules/redis/index.js:279:14)
    at Socket.emit (events.js:209:13)
    at emitErrorNT (internal/streams/destroy.js:91:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 6379
} 

Am i'm missing something?

Laura Beatris
  • 1,782
  • 7
  • 29
  • 49

1 Answers1

1

Because you're passing options wrong, hence it's pickup the default. check the documentation again, you'll see that redis config goes into redis key of the config

example

var q = kue.createQueue({
  prefix: 'q',
  redis: {
    port: 1234,
    host: '10.0.50.20',
    auth: 'password',
    db: 3, // if provided select a non-default redis db
    options: {
      // see https://github.com/mranney/node_redis#rediscreateclient
    }
  }
});

in your case

this.kue = kue.createQueue({ redis: redisConfig })
Tuan Anh Tran
  • 6,807
  • 6
  • 37
  • 54
  • i'm passing my cluster as the host and i'm still getting the error – Laura Beatris Nov 13 '19 at 16:49
  • when i'm running a local instance of redis with docker, i don't have a connection problem but my redis instance are running totally fine at aws and i just want to know the reason that it's not working with the queue :( – Laura Beatris Nov 14 '19 at 01:57