Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hangfire does not process recurring jobs unless dashboard is open

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?

like image 515
Kandus MacMillan Avatar asked May 19 '17 15:05

Kandus MacMillan


1 Answers

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.

like image 146
Ilya Chumakov Avatar answered Nov 07 '22 01:11

Ilya Chumakov