HangfireIO / HangfireIO/Hangfire
How to Extend Timeout of Hangfire Job
- Dominant language
- C#
- Stars
- 10.1k
- Forks
- 1.8k
- Avg merge
- 1h 19m
- Merged PRs (30d)
- 1
Description
I am new to Hangfire. I am using Hangfire 1.7.6 with SQL Server back end, and entity framework. I have a requirement to set up a Hangfire job for 1 time use that can be manually triggered from the Hangfire dashboard. I set up a Recurring job with a start cron expression of "0 0 31 2 0" to prevent the recurring job from recurring and make it manually triggered. The end user will then trigger the job at will for a 1 time run. The job takes takes more than 30 minutes to execute. If the end user keeps the Hangfire dashboard open, the job runs to completion (well over 30 minutes). However, we cannot be certain that or VPN will allow the end user to be connected long enough for the job to finish. If we do not keep the Hangfire dashboard open, the job stops after 30 minutes and we do not want to restart the job.
Our long running job takes several hours to run.
My understanding is that Hangfire is supposed to run the thread/job for 30 minutes and then put it on a new thread or job and resume. In my case, it just stops at 30 minutes. I presume because I have the cron expression of "0 0 31 2 0."
I have set the sql server storage options
var sqlOptions = new SqlServerStorageOptions
{
PrepareSchemaIfNecessary = false,
//InvisibilityTimeout = TimeSpan.FromHours(35),
SlidingInvisibilityTimeout = TimeSpan.FromHours(35)
};
GlobalConfiguration.Configuration.UseSqlServerStorage("AContext", sqlOptions);
RecurringJob.AddOrUpdate("Datacleanup", () => Datacleanup(), "0 0 31 2 0", TimeZoneInfo.Local);
Is there a way I can change the timeout to be more than 30 minutes? I have tried setting the Invisibility Timeout and the Sliding Visibility timeout and neither has any noticeable effect.
Contributor guide
Research direction
Start with the RecurringJob.AddOrUpdate call and the SqlServerStorageOptions configuration shown in the issue. Trace how the 30-minute timeout is applied to long-running jobs and whether the dashboard connection or cron expression affects execution. Done means documenting or correcting the configuration so a multi-hour job can complete without requiring the dashboard to remain open.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, sql
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100