MongoDB connection problems on Azure

后端 未结 2 1803

We have an ASP.NET MVC application deployed to an Azure Website that connects to MongoDB and does both read and write operations. The application does this iteratively. A few th

2条回答
  •  温柔的废话
    2021-02-04 09:07

    Are you using mongoDB in a VM? It seems to be a network problem. This kind of transient faults should occur, so the best you can do is implement a retry pattern or use a lib such as Polly to do that:

    Policy
        .Handle()
        .Retry(3, (exception, retryCount) =>
        {
            // do something 
        });
    

    https://github.com/michael-wolfenden/Polly

提交回复
热议问题