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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With