[CSHARP-3217] A timeout occured after 30000ms selecting a server using CompositeServerSelector Created: 29/Sep/20  Updated: 27/Oct/23  Resolved: 30/Sep/20

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Todd Braley Assignee: Unassigned
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

I'm trying to create a Kubernetes Side-Car container that will help manage the mongo replica set. However, I can't seem to use the CSharp driver to connect to a mongo instance that was started with the --replSet option. I'd like for my C# application to send the 
replSetInitiate command.  However, the driver refuses to connect by throwing a Timeout exception.

var _mongoClient = new MongoClient("mongodb://localhost:30006/?replicaSet=rs0");
var dbAdmin = _mongoClient.GetDatabase("admin");
var result = await dbAdmin.RunCommandAsync<BsonDocument>("{replSetInitiate : {} }");

 



 Comments   
Comment by Todd Braley [ 01/Oct/20 ]

Thanks, Dmitry

The direct connection mode works. I didn't see that in the documentation.

Comment by Dmitry Lukyanov (Inactive) [ 30/Sep/20 ]

Hey stbraley@gmail.com ,

In addition to Asya's comment, you cannot connect to an un-initiated replica set without direct connection mode. You have to use a directconnection=true (or in older driver versions: connect=direct) to connect to an un-initiated replica set.

When replica set will be initialized then you will be able to use the regular connection string with ?replicaSet=rs0 and without directconnection=true.

Comment by Asya Kamsky [ 29/Sep/20 ]

Shouldn't you omit replicaSet=rs0 since the replica set doesn't exist yet?

Generated at Wed Feb 07 21:44:42 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.