【发布时间】:2022-02-22 21:56:59
【问题描述】:
我正在尝试使用 .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 repo 中查看本教程的完整代码:https://github.com/walpoles93/AspNetCoreMongoDb
我还尝试下载此存储库并添加我的 mongo 用户和密码,但仍然出现同样的错误。
我得到的错误是:
System.TimeoutException: A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 } }. Client view of cluster state is { 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: An exception occurred while opening a connection to the server.
以前有人遇到过这个问题吗?
【问题讨论】:
标签: .net mongodb asp.net-core mongodb-query