OptimalBits / bull

Premium Queue package for handling distributed jobs and messages in NodeJS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TLS Support in redis connection

a-samad opened this issue · comments

TLS Support in Redis connection

Connection Code

var redisConfig = "rediss://user:secret@url:6379/0?tls=true&connectionName=event_service&socket_keepalive=true";

// Initiating Bull Queue
var jobs = new bullQueue('EventService', redisConfig);
try{
      jobs.add({
          body: {some_json},
          jobName: 'base_job',
          title: 'Event factory job initiated: ' + new Date()
      });
} catch(error) {
    console.log(error);
}

jobs.process(function (job, done) {
    EventFactory.create(job, function (err) {
        if (err) {
            done(err)
        }
        done();
    });
});

I am using AWS Elastic Cache with Redis 7.1 with TLS, I am connected with the Elastic Cache but jobs are not adding to the queue. No error in the catch block while adding the body to the job

3.4.2

Since .add returns a promise you will never get a proper error handling here, you need to use await:

try{
      await jobs.add({
          body: {some_json},
          jobName: 'base_job',
          title: 'Event factory job initiated: ' + new Date()
      });
} catch(error) {
    console.log(error);
}

jobs.process(function (job, done) {
    EventFactory.create(job, function (err) {
        if (err) {
            done(err)
        }
        done();
    });
});

If you are new to Bull, please consider using BullMQ instead: https://github.com/taskforcesh/bullmq

Thank you for your help @manast, But I have resolved this issue, As I said in the post I am using AWS Elastic Cache with Redis 7.1 with TLS, I have to change the Redis connection string a little bit and now it is adding the jobs and picking it properly. The issue is that there is no proper help in OptimusBull docs about that. I have to find it from IORedis and node-redis packages help.

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.