[CSHARP-1905] Interminable heartbeat attempts in ServerMonitor class after a failed conection Created: 01/Feb/17  Updated: 27/Oct/23  Resolved: 02/Mar/17

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

Type: Task Priority: Minor - P4
Reporter: Alexey Butalov Assignee: Robert Stam
Resolution: Works as Designed Votes: 0
Labels: question
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

MS Windows 10 x64, MongoDB 3.2,3.4, .Net Framework 4.5



 Description   

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



 Comments   
Comment by Robert Stam [ 02/Mar/17 ]

This is intentional.

We don't know if the credentials are invalid or just haven't been added to the database yet. At any moment a DBA might add the missing credentials and then the heartbeat attempts would start working.

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