我试图连接到FreeBSD服务器上在Mono上运行的C#服务器上的mongodb-atlas集群。我正在使用mongodb C#驱动程序。
我正在尝试使用以下连接URL连接到集群。
var connectionUrl = $"mongodb://{dbUsername}:{dbPassword}@staging-shard-00-00-iksnu.mongodb.net:27017,staging-shard-00-01-iksnu.mongodb.net:27017,staging-shard-00-02-iksnu.mongodb.net:27017/{dbName}?ssl=true&replicaSet=Staging-shard-0&authSource=admin&retryWrites=true";
var client = new MongoClient(connectionUrl);
我遇到此错误:
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/staging-shard-00-00-iksnu.mongodb.net:27017" }", EndPoint: "Unspecified/staging-shard-00-00-iksnu.mongodb.net:27017", State: "Disconnected", Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server. ---> System.TypeLoadException: Could not resolve type with token 01000056 (from typeref, class/assembly MongoDB.Bson.Serialization.Serializers.ElementAppendingSerializer`1, MongoDB.Bson, Version=2.7.3.0, Culture=neutral, PublicKeyToken=null)
我相对确定:
它不是实际的连接字符串-该字符串在本地可用(长格式和短格式)
它不会基于IP被拒绝-使用mongo shell时我可以连接到集群
版本信息
有什么明显的方法可以解决我丢失的问题吗? 这似乎与this stack overflow thread相关联,但是尚未解决。