原来如此~ 2022-02-25 18:41 采纳率: 40%
浏览 22
已结题

.net mvc5 集成 hangfire 使用 mongodb存储报错

新创建的一个项目,为了测试。

vs2019, docker安装最新版本的mongodb, 数据库连接信息正确,没有问题。


 public void ConfigureServices ( IServiceCollection services )
        {
            
            services.AddHangfire( configura =>
            {
                var mongoUrlBuilder = new MongoUrlBuilder( "mongodb://xxx:xxx@xxxxx/hangfire?authSource=hangfire" );
                var mongoClient = new MongoClient( mongoUrlBuilder.ToMongoUrl() );
                //指定存储介质
                configura
                .SetDataCompatibilityLevel( CompatibilityLevel.Version_170 )
                .UseSimpleAssemblyNameTypeSerializer()
                .UseRecommendedSerializerSettings()
                .UseMongoStorage( mongoClient, mongoUrlBuilder.DatabaseName, new MongoStorageOptions()
                {
                    MigrationOptions = new MongoMigrationOptions
                    {
                        MigrationStrategy = new MigrateMongoMigrationStrategy(),
                        BackupStrategy = new CollectionMongoBackupStrategy()
                    },
                    Prefix = "hangfire",
                    CheckConnection = true
                } ) ;
                configura.UseConsole();
            } );
            services.AddHangfireServer( serverOptions =>
            {
                serverOptions.ServerName = "Hangfire.Mongo server 1";
            } );
        }


public void Configure ( IApplicationBuilder app, IWebHostEnvironment env )
{
...
app.UseHangfireDashboard();
...
}
引发的异常报错,且数据库中,没有生成对应的集合。
:“System.InvalidOperationException”(位于 Hangfire.Mongo.dll 中)
“System.InvalidOperationException”类型的异常在 Hangfire.Mongo.dll 中发生,但未在用户代码中进行处理
Could not complete migration. Never acquired lock within allowed time: 00:01:00
Either another server did not complete the migration or migration was abruptly interrupted
If migration has been interrupted you need to manually delete 'hangfire.migrationLock' and start again.
  • 写回答

1条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      问题事件

      • 系统已结题 3月9日
      • 已采纳回答 3月1日
      • 修改了问题 2月25日
      • 创建了问题 2月25日

      悬赏问题

      • ¥200 把公众号页面和文章,嵌入到其他平台!就像搬家一样!
      • ¥20 matlab编程问题。详情如下,利用chatgpt写的代码总是达不到要求。
      • ¥15 matlab画三维流场
      • ¥100 IIC通讯数据算法分析
      • ¥15 matlab 绘制涡流场
      • ¥15 依存句法分析如何与BERT模型及GCN相结合
      • ¥66 有偿收一个会Python 与unitysocket通信,会简单mediapipe手势识别的哥
      • ¥15 药店卖药设计使利润最大
      • ¥15 模拟银行实现VIP服务
      • ¥20 ECU在实车上can通讯失败或不稳定