1

i got error when i queue with bull library in node js, the error is like this :

     Error: read ECONNRESET at TCP.onStreamRead 
    - - errno: -104,
   - - code: 'ECONNRESET',
   - - syscall: 'read'
   - - }

and

 MaxRetriesPerRequestError: Reached the max retries per request limit (which is 20). Refer to "maxRetriesPerRequest" option for details.

this my code :

const imageQueue = new Bull("imageQueue", process.env.REDIS_URL);

3 Answers3

6

error solved successfully by adding tls

const imageQueue = new Bull("imageQueue", process.env.REDIS_TLS_URL, {
  redis: { tls: { rejectUnauthorized: false } },
});
0

bull uses ioredis to connect, and allows a third opts parameter in the Queue constructor. According to the source code it looks for a redis property within those opts.

You might try this to raise the retry limit to 100.

const opts = {redis:{maxRetriesPerRequest:100}}
const imageQueue = new Bull("imageQueue", process.env.REDIS_URL, opts);

But, also, you may be using Heroku's redis service more intensively than they allow for the free tier (if that's what you use).

O. Jones
  • 103,626
  • 17
  • 118
  • 172
  • thank you for answering, currently there is still an **ECONNRESET** error. for your information on my local computer it works, error only when connected redis heroku. – putu eka mulyana Aug 27 '21 at 06:57
  • Aha, in that case you're probably exceeding Heroku's redis-service limits. I think they charge hour-by-hour, so you could provision a more expensive plan and see if it works better for you. That would test my hypothesis of exceeding their limits. – O. Jones Aug 27 '21 at 10:25
  • my plan has Premium 0, is it still lacking? – putu eka mulyana Aug 27 '21 at 10:44
0

You can do something similar as what is suggested on the npm package docs.

  // This is the default value of `retryStrategy`
  retryStrategy(times) {
    const delay = Math.min(times * 50, 2000);
    return delay;
  },
});

https://www.npmjs.com/package/ioredis#user-content-auto-reconnect

You'd need to send this redis configuration when creating the bull queue.

rogeliorv
  • 81
  • 6