[英]There are no active servers. Background tasks will not be processed
I have a problem which I already looking at it for a few days and still have no solution. 我有一个问题,已经几天了,但仍然没有解决方案。
I found this exception in my C# web app log. 我在C#Web应用程序日志中发现了此异常。
[2015-12-03 13:56:06] [ERROR] [] [Error occurred during execution of 'Server Bootstrapper' component.
[2015-12-03 13:56:06] [错误] [] [执行“服务器引导程序”组件时发生错误。 Execution will be retried (attempt 120 of 2147483647) in 00:05:00 seconds.] [System.Data.SqlClient.SqlException (0x80131904): Login failed for user "A Network account".
将在00:05:00秒内重试执行(尝试2147483647的120)。] [System.Data.SqlClient.SqlException(0x80131904):用户“ A网络帐户”的登录失败。
It appears to me that it is using the network account to access the SQL database and because that network account is not granted access to the database, hence login failed and server cannot startup. 在我看来,它正在使用网络帐户访问SQL数据库,并且因为未授予该网络帐户访问数据库的权限,因此登录失败并且服务器无法启动。
However, when I go to the Hangfire dashboard, I can see the recurring jobs, which seems to me that hangfire can access the database with the right account for retrieving the recurring jobs. 但是,当我转到Hangfire仪表板时,可以看到重复的作业,在我看来,hangfire可以使用正确的帐户访问数据库以检索重复的作业。
Also, in the IIS server, we already set the Identity to "ApplicationPoolIdentity" for the application pools. 另外,在IIS服务器中,我们已经将应用程序池的标识设置为“ ApplicationPoolIdentity”。 Hence, we should use the virtual account instead of the network account.
因此,我们应该使用虚拟帐户而不是网络帐户。
May I know anyone has the similar problem and have the solution. 我是否可以知道有人遇到类似的问题并找到解决方案。 Really appreciate for your help!!
非常感谢您的帮助!
I ran into the same issue using Hangfire with SQL Server and EntityFramework Code First where EntityFramework was responsible for creating the database, so this suggestion is based purely off of that scenario. 我在将Hangfire与SQL Server和EntityFramework Code First结合使用时遇到了相同的问题,其中EntityFramework负责创建数据库,因此,该建议完全基于这种情况。
If you are using EF Code First, your database isn't created until the context is created and accessed for the first time. 如果您使用的是EF Code First,则直到第一次创建并访问上下文后,才会创建数据库。
This means that at App Start your database might not exist. 这意味着在“应用程序启动”中,您的数据库可能不存在。 Hangfire won't create the database, it only creates the tables in an already existing database.
Hangfire不会创建数据库,它只会在现有数据库中创建表。
So what you might be seeing is: 因此,您可能会看到的是:
The way I solved it was to make sure that even if the database is empty (not tables), it is at least created. 我解决问题的方法是确保即使数据库为空(不是表),也至少要创建它。 This was hangfire can access it to install it's tables and start, and EF can access it, and create it's schema.
hangfire可以访问它以安装它的表并启动,而EF可以访问它并创建它的模式。
Also, (and this probably isn't it), GlobalConfiguration.Configuration.UseSqlServerStorage() should run first before other Hangfire startup configuration. 另外,(也许不是),GlobalConfiguration.Configuration.UseSqlServerStorage()应该在其他Hangfire启动配置之前先运行。
Hope that helps! 希望有帮助!
Steve 史蒂夫
您应该创建后台作业服务器实例,请参见此处的文档
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.