Bull - Reached the max retries per request limit
Asked Answered
J

5

7

I am using npm bull to add my queue job to handle about sending mail for my project. It runs no problems for a long time, but recently, it shows this error: Error while handling task collect-metrics: Reached the max retries per request limit (which is 10). Refer to "maxRetriesPerRequest" option for details. error log And I checked in redis-cli: key *, it didn't show any key. The bull module support @bull-monitor/express to monitor the job, but since the error shows, I couldn't access the monitor bull admin panel here is my code

Jeff answered 18/4, 2022 at 7:0 Comment(0)
W
7

I faced this problem as well when I deployed my application to production. It turns out that Bull.js doesn't automatically allow a redis connection over TLS, especially the fact that the production environment is already running over TLS. So what fixed it for me was setting tls to true, and enableTLSForSentinelMode to false in the Redis options of my queue. Here's a sample code:

const myQueue = new Queue('my_queue', YOUR_REDIS_URL, {
  redis: { tls: true, enableTLSForSentinelMode: false },
  ...other queue options
})
Wulf answered 8/8, 2022 at 20:28 Comment(3)
For users of NestJS, be aware the difference in structure of RedisOpts. In Nest, you can pass the tls option can be included in the opts passed to the forRoot method. Here in Bull, if you add the tls option in the config object as the second argument, it will be ignored.Penury
I'm trying to connect to a redis server on the cloud (render.com specifically) however my BullMQ module for Nest JS fails connection. Any idea what the correct configuration for it is? @PenuryUndeceive
@Undeceive I have never used render.com before, so I don't know anything about that, sorry!Penury
K
1

Bull can't find Redis to connect with. I'm was using bull in local environment and there is no problem, on the cloud the bull shows me the same error.

so in local environment it's connect to 127.0.0.1:6379, but in cloud you don't have this port so you need to specific the redis's username, redis's password and redis's port.

Kikuyu answered 30/7, 2022 at 9:11 Comment(0)
S
0

I was able to solve this by setting some configuration settings on the Queue object as such:

export const networkUnreadsQueue = new Queue(
    'Network Unreads Notifications',
    process.env.REDIS_URL,
    {
        redis: { maxRetriesPerRequest: null, enableReadyCheck: false },
    }
);

Alternatively it is possible to update to a newer version of bull-board if you're using that, as it made my application throw the same error. You can see the same issue being discussed on their github page, resulting in a PR for version 5.0.0 that fixes the issue (but has breaking changes in the API, on how imports are structured).

Specify answered 14/3, 2023 at 13:12 Comment(0)
W
-1

You are able to set your limit, if you want for example without limits just set maxRetriesPerRequest: null. But maybe it is bad for performance and etc.

Wellbeloved answered 7/3, 2024 at 19:50 Comment(0)
F
-1

-1 You are able to set your limit, if you want for example without limits just set maxRetriesPerRequest: null. But

maybe it is bad for performance and etc.

Flitch answered 30/4, 2024 at 12:13 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Kanazawa

© 2022 - 2025 — McMap. All rights reserved.