【问题标题】:Why Hangfire server shuts down?为什么 Hangfire 服务器关闭?
【发布时间】:2021-09-06 12:14:21
【问题描述】:

我有一个使用 Hangfire 的 .net 5 应用程序。 问题是,一旦应用程序完成启动,hangfire 服务器就会关闭。如果我在Startup.cs 的最后一行放置断点,则hangfire 服务器是活动的。 没有记录错误。

这可能是什么原因?

以下是用于添加 Hangfire 的代码。

public void ConfigureServices(IServiceCollection services)
{

 services.AddHangfire(config =>
            {
                config.UseSqlServerStorage(configuration.GetConnectionString("HangfireDefaultConnection"), new SqlServer.SqlServerStorageOptions
                {
                    CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),
                    SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),
                    QueuePollInterval = TimeSpan.Zero,
                    UseRecommendedIsolationLevel = true,
                    DisableGlobalLocks = true,
                    SchemaName = "dbo.WR_Hangfire",
                });
            });
....

}

public void Configure(IApplicationBuilder app)
{
...
 app.UseHangfireServer();
...
}

【问题讨论】:

    标签: hangfire


    【解决方案1】:

    原来app.UseHangfireServer(); 已被弃用,这就是问题所在。通过services.UseHangfireServer()注册服务器解决。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-06
      • 2020-06-19
      • 1970-01-01
      • 2020-04-22
      • 2017-04-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多