多个服务器在 HANGFIRE 中生成错误 500

iag*_*res 5 c# kubernetes hangfire asp.net-core

当我使用 pod 管理的 Kubernetes 架构将应用程序投入生产时,它有可能扩展,所以今天它有两台服务器运行相同的应用程序,hangfire 识别两者但返回错误 500

Unable to refresh the statistics: the server responded with 500 (error). Try reloading the page manually, or wait for automatic reload that will happen in a minute.
Run Code Online (Sandbox Code Playgroud)

但是当我离开只有一台服务器的测试应用程序时,hangfire 正常工作。

挂火配置:

Unable to refresh the statistics: the server responded with 500 (error). Try reloading the page manually, or wait for automatic reload that will happen in a minute.
Run Code Online (Sandbox Code Playgroud)

错误

Nug*_*ugs 0

我们通过将 DataProtectionKey 保留在 Redis 中以供所有副本读取来解决此问题。

services.AddDataProtection().PersistKeysToStackExchangeRedis(redis, $yourprefix::DataProtectionKeys");
Run Code Online (Sandbox Code Playgroud)