diff --git a/src/Mongo/Mongo.csproj b/src/Mongo/Mongo.csproj index 8756035..695cb3a 100644 --- a/src/Mongo/Mongo.csproj +++ b/src/Mongo/Mongo.csproj @@ -6,7 +6,7 @@ - + diff --git a/src/Mongo/MongoReplicaSetResource.cs b/src/Mongo/MongoReplicaSetResource.cs index 2281b01..2467d3b 100644 --- a/src/Mongo/MongoReplicaSetResource.cs +++ b/src/Mongo/MongoReplicaSetResource.cs @@ -1,11 +1,11 @@ -using System; +using System; using System.Threading.Tasks; using MongoDB.Bson; using MongoDB.Driver; namespace Squadron { - /// + /// public class MongoReplicaSetResource : MongoReplicaSetResource { } /// @@ -19,7 +19,7 @@ public class MongoReplicaSetResource : public override async Task InitializeAsync() { await base.InitializeAsync(); - var client = new MongoClient(ConnectionString + "/?connect=direct"); + var client = new MongoClient(ConnectionString); BsonDocument rsConfig = CreateReplicaSetConfiguration(); var command = new BsonDocumentCommand(new BsonDocument { diff --git a/src/Mongo/MongoResource.cs b/src/Mongo/MongoResource.cs index 227cf67..cdef7f9 100644 --- a/src/Mongo/MongoResource.cs +++ b/src/Mongo/MongoResource.cs @@ -28,7 +28,8 @@ public override async Task InitializeAsync() { await base.InitializeAsync(); ConnectionString = - $"mongodb://{Manager.Instance.Address}:{Manager.Instance.HostPort}"; + $"mongodb://{Manager.Instance.Address}:{Manager.Instance.HostPort}" + + "/?directConnection=true"; _client = GetClient(); await Initializer.WaitAsync(new MongoStatus(_client)); @@ -43,7 +44,7 @@ private MongoClient GetClient() { return new MongoClient(new MongoClientSettings { - ConnectionMode = ConnectionMode.Direct, + DirectConnection = true, ReadConcern = ReadConcern.Majority, WriteConcern = WriteConcern.Acknowledged, Server = new MongoServerAddress(Manager.Instance.Address, Manager.Instance.HostPort),