deebugger
deebugger

Reputation: 145

Bullmq doesn't pull job from a Redis over TLS

I'm using the very basic example (const queue = new Queue('Paint')) from the https://www.npmjs.com/package/bullmq page - everything works fine (it defaults to localhost:6379).

However when I add a connection (new Queue('Paint', { connection })) that's based on a TLS access to Redis (rediss://...), I can still push jobs into the queue (which I see in the Redis itself), but none of these jobs get pulled by the worker.

Maybe I'm missing some hidden flag?

Thanks!

-Dror

Upvotes: 1

Views: 4764

Answers (2)

Arvid
Arvid

Reputation: 101

This happens due to manual and incomplete parsing of redis url here: https://github.com/OptimalBits/bull/blob/develop/lib/queue.js#L308

rediss:// vs redis:// is simply not taken into account.

To workaround this issue I had to add more keys to additional 'redis' key:

export const REDIS_CONNECTION: Redis.RedisOptions = {
  ...(REDIS_URL.startsWith('rediss://') ? { tls: {} } : null), // This trick makes sure SSL would work
  retryStrategy: (times) => {
    // reconnect after
    return Math.min(times * 50, 2000);
  },
};

export const queue = new Bull<JobData>('foobar', REDIS_URL, {
  redis: REDIS_CONNECTION,
...

Upvotes: 2

deebugger
deebugger

Reputation: 145

I found out what happened - although I'm still not sure why:

I was using ioredis as the connection for bull when the problem surfaced. When I replaced it with redis it started working properly, pulling jobs out of the queue.

Both packages has full support for Redis over TLS, but for some reason the integration with bull didn't work out for ioredis.

-Dror

Upvotes: 1

Related Questions