Bull: Connection time out during queue add

Created on 28 Jun 2019  Â·  6Comments  Â·  Source: OptimalBits/bull

Description

We are getting Error: connect ETIMEDOUT while adding a new job to queue. It used to work fine, but suddenly getting connection timed out.

 Error: connect ETIMEDOUT
     at Socket.<anonymous> (/home/ubuntu/securenyx360-api/node_modules/ioredis/built/redis.js:298:31)
     at Object.onceWrapper (events.js:255:19)
     at Socket.emit (events.js:160:13)
     at Socket._onTimeout (net.js:412:8)
     at ontimeout (timers.js:458:11)
     at tryOnTimeout (timers.js:296:5)
     at Timer.listOnTimeout (timers.js:259:5)

We are using EalsticCache with a t2.medium instance. This is our code for adding new job

function addToQueue(name, payload) {

   let addOptions = {
        attempts            : 2,
        timeout             : 25000,
        delay               : 100
    };

   Queue[name].add(payload, addOptions)
       .then((job) => {
           console.log(`[${name}] Job added with in ID ${job.id}`)
       })
       .catch(e => {
           console.log(`[${name}] Error adding Job`, e);
       });
}

Redis config is fine and we can connect to redis from our ec2 instance using redis-cli. Any idea what can go wrong?

Bull version

3.4.4

Most helpful comment

Please try to increase connectTimeout on ioredis options _when creating a Queue_, the default as far as I know is 10000 milliseconds. Job timeout is not the same thing.

const myQueue = new Queue('my-queue', {
    // do not pass redis url in constructor if supplying ioredis options directly:
    redis: {
        host: 'localhost',
        port: 6379,
        db: 0,
        password: 's3cret',
        connectTimeout: 30000
    },
    // ... another Queue options ...
});

Also you can try to play around this option: https://github.com/luin/ioredis#reconnect-on-error.

All 6 comments

Please try to increase connectTimeout on ioredis options _when creating a Queue_, the default as far as I know is 10000 milliseconds. Job timeout is not the same thing.

const myQueue = new Queue('my-queue', {
    // do not pass redis url in constructor if supplying ioredis options directly:
    redis: {
        host: 'localhost',
        port: 6379,
        db: 0,
        password: 's3cret',
        connectTimeout: 30000
    },
    // ... another Queue options ...
});

Also you can try to play around this option: https://github.com/luin/ioredis#reconnect-on-error.

at least it relies on another library — ioredis, and ioredis in turn relies on Redis server. Default settings of all these components are targeted to cover requirements of the most of users, ones having specific setup and/or requirements of course should spent some time to configure software they use

@stansv i should suspect when instantiate a Queue it keeps the connection alive, but for some reason i am getting E_TIMEDOUT when trying to call Queue#add.

@stansv the problem is caused by ioredis

@r3wt please mind your manners. Even if you delete messages they are sent to all the participants of this thread. I will close for now since timeouts are normally due to external factors and not from Bull itself.

@manast ok, i will try and contain my frustration at this bullshit. just for you. but still, you closed someone else's thread because of me. perhaps that was a bit too hamfisted of a response, no? For all you know this thread may have been open for a reason.

Was this page helpful?
0 / 5 - 0 ratings