我正在尝试使用 .net Core 连接到 Mongo DB,但在调用 API 时遇到了超时错误。
我按照这篇教程操作:https://medium.com/swlh/how-to-use-a-mongodb-database-in-a-asp-net-core-web-api-application-b0451ae314f5
你可以查看这个 git 库中的完整代码:https://github.com/walpoles93/AspNetCoreMongoDb
我还尝试下载此存储库并添加我的 Mongo 用户名和密码,但仍然出现相同的错误。
我遇到的错误是:
System.TimeoutException: 在使用 CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 } } 选择服务器后的 30000ms 后发生超时。集群状态的客户端视图为{ ClusterId : "1", ConnectionMode : "ReplicaSet", Type : "ReplicaSet", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 1, EndPoint : "Unspecified/cluster0-shard-00-00.tvnqj.mongodb.net:27017" }", EndPoint: "Unspecified/cluster0-shard-00-00.tvnqj.mongodb.net:27017", ReasonChanged: "Heartbeat", State: "Disconnected", ServerVersion: , TopologyVersion: , Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: 在打开到服务器的连接时发生异常。
有人遇到过这个问题吗?