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

.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条回答 默认 最新

  • Yijing Sun 2022-02-28 13:47
    关注

    你好,
    请问你有尝试过在选项中增加等待时间**MigrationLockTimeOut **吗?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

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

悬赏问题

  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持