Hangfire does not process recurring jobs unless dashboard is open
Asked Answered
B

1

8

When I log into the server and open dashboard, it shows recurring jobs with the next execution in the past. Within seconds it triggers processes them automatically, but if I don't log in and open the dashboard, the recurring jobs are not triggered.

It appears that Hangfire is running as expected and processing jobs.
Why will it not trigger without me looking at it?

Bucolic answered 19/5, 2017 at 15:31 Comment(0)
W
7

It's a usual problem if a Hangfire server runs in a web application. The jobs are not triggered because the web server has stopped the app due to user inactivity.

By default, Hangfire Server instance in a web application will not be started until the first user hits your site. Even more, there are some events that will bring your web application down after some time (I’m talking about Idle Timeout and different app pool recycling events). In these cases your recurring tasks and delayed jobs will not be enqueued, and enqueued jobs will not be processed.

Read the docs to prevent it: Making ASP.NET application always running.

Another solution is to migrate your Hangfire server from a web application to a console app or a windows service.

Whitesell answered 19/5, 2017 at 19:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.