question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to Connect to MongoDb on a Fresh Install in an ASP.NET Core (5.0) Web Application

See original GitHub issue

Using the latest libraries from Hangfire.Core (v1.7.28) and Hangfire.Mongo (v0.7.28), I am unable to get a connection to my MongoDB database. I’m using the connection string:

mongodb+srv://prd-core-db:*******@prd-us.*****.mongodb.net/core?retryWrites=true&w=majority

The connection string works perfectly for the other aspects of the application, but after adding the nuget packages, configuring the startup.cs class, I get the following error when running the application:

System.InvalidOperationException: 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.

I’ve tried modifying the MigrationStrategy and the BackupStrategy, but doing so does nothing.

Is there a fix to this? Perhaps I need to create a new collection in Mongo (or set of collections with another script)?

image

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dotnetalldaycommented, Jan 21, 2022

@gottscj My DatabaseName property is valid - “hangfire”. See attachment - my database name is highlighted. What I’m not understanding is what Hangfire is doing with Mongo on startup. Is Hangfire supposed to create a Collection in the DB? If so, I’m not seeing anything being created during the timeout period. Is there documentation out there that lists what Collections will be created by Hangfire when the initialization is complete? Perhaps I can create those collections beforehand with better luck.

Image 001

1reaction
gottscjcommented, Jan 15, 2022

@dotnetallday,

Thanks for submitting. I’ll try to reproduce. Did you try to manually delete the migrationLock entity in the DB? Are you running multiple instances or just one?

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create a web API with ASP.NET Core and MongoDB
This tutorial demonstrates how to create an ASP.NET Core web API using a MongoDB NoSQL database.
Read more >
Can't connect to Mongodb Atlas from Render Web-Hosted ...
I have a small webapp that runs locally with a local MongoDB database just fine. I moved it to Render, and created a...
Read more >
Create a RESTful API with .NET Core and MongoDB - YouTube
Want to build a web application with . NET Core and MongoDB ? In this video tutorial, Nic Raboy shows how to build...
Read more >
ASP.NET Core 6 REST API Tutorial | MongoDB Database
How to build ASP. NET Core REST API from scratch using Visual Studio 2022, ASP. NET 6 and MongoDB database. Use the following...
Read more >
Error: couldn't connect to server 127.0.0.1:27017
I'm following the install guide “Install MongoDB Community Edition on macOS”. I'm getting the following error: MongoDB shell version v4.2.3
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found