Hi,
I am using “Hangfire 1.5” with “Hangfire.MongoDB”, MongoDB as a storage.
Sometime It just stops the background process after some time execution. When I am checking the log there is no any error found.
Below is my configuration:
//******************* Imp. Setting for HangFire ************************************************
bool hangfire_use_sql = Convert.ToBoolean(ConfigurationManager.AppSettings[“is_hangfire_use_sql”]);
if (hangfire_use_sql)
{
var options = new Hangfire.SqlServer.SqlServerStorageOptions
{
PrepareSchemaIfNecessary = true,
InvisibilityTimeout = TimeSpan.FromHours(2) // default value
};
GlobalConfiguration.Configuration
.UseSqlServerStorage(ConfigurationManager.AppSettings["hangfire_sqldbConnection"].ToString(), options);
}
if (!hangfire_use_sql)
{
app.UseHangfire(config =>
{
config.UseMongoStorage(ConfigurationManager.AppSettings["hangfire_mongodbConnection"].ToString(), ConfigurationManager.AppSettings["hangfire_mongodb"].ToString()
, new Hangfire.Mongo.MongoStorageOptions
{
Prefix = "hf_",
InvisibilityTimeout = TimeSpan.FromMinutes(120)
});
});
}
app.UseCookieAuthentication(new CookieAuthenticationOptions());
var dashboardOptions = new DashboardOptions()
{
AuthorizationFilters = new[] { new MyRestrictiveAuthorizationFilter() }
};
app.UseHangfireDashboard("/hangfire",dashboardOptions);
var backgroundJobServerOptions = new BackgroundJobServerOptions
{
ServerName = String.Format("{0}_{1}",Environment.MachineName,Guid.NewGuid().ToString())
};
app.UseHangfireServer(backgroundJobServerOptions);
//*********************************************************************************************
Please suggest help as I am stuck in production environment.