-
Type:
Task
-
Resolution: Works as Designed
-
Priority:
Minor - P4
-
None
-
Affects Version/s: 2.4.1
-
Component/s: Connectivity
-
Environment:MS Windows 10 x64, MongoDB 3.2,3.4, .Net Framework 4.5
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Hello,
I don't know is this a bug or a feature, but in fact it is very annoying thing.
If you try to connect to a MongoDB server with a wrong login\password or an another incorrect property that prevents establishing of a successful connection, an instance of MongoServer class will attempt to connect to the server while the process active.
var server = new MongoServer(anyWrongProps); server.Connect(); // an exception should be raised here
After that the interminable loop
while (!heartbeatCancellationToken.IsCancellationRequested)
will be in progress in MongoServer.MonitorServerAsync() method.
I have tried to fix it with the following code
ClusterRegistry.Instance.UnregisterAndDisposeCluster(server.Cluster);
Seems it works, but perhaps it can be a reason of some problems. I don't know is this safe.
Best regards,
Alex