Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-1905

Interminable heartbeat attempts in ServerMonitor class after a failed conection

    • Type: Icon: Task Task
    • Resolution: Works as Designed
    • Priority: Icon: Minor - P4 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

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            alexeybut Alexey Butalov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: