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

2.3.0 driver does not honor ConnectTimeout setting

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Connectivity
    • None
    • Environment:
      Windows Server 2012, Visual Studio 2017 Preview, Azure Functions
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      I setting the ConnectTimeout property with the following code:

      MongoUrl mongoUrl = new MongoUrl(strMongoDBAtlasUri);
      var settings = MongoClientSettings.FromUrl(mongoUrl);
      settings.ConnectTimeout = new System.TimeSpan(0, 0, 5);
      var client = new MongoClient(settings);

      while using a MongoDB Atlas URI (strMongoDBAtlasUri above).

      I purposely provide incorrect user credentials in the Uri, but the exception is still thrown after 30 seconds (default value) instead of the 5 seconds I specified above.

      The error message is the following:

      Message "A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = WritableServerSelector, LatencyLimitingServerSelector

      { AllowedLatencyRange = 00:00:00.0150000 }

      }. Client view of cluster state is { ClusterId : \"1\", ConnectionMode : \"ReplicaSet\", Type : \"ReplicaSet\", State : \"Disconnected\", Servers : [{ ServerId: \"

      { ClusterId : 1, EndPoint : \"Unspecified/cluster0-shard-00-00-nebpx.mongodb.net:27017\" }

      \", EndPoint: \"Unspecified/cluster0-shard-00-00-nebpx.mongodb.net:27017\", State: \"Disconnected\", Type: \"Unknown\", HeartbeatException: \"MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server. --> MongoDB.Driver.MongoAuthenticationException: Unable to authenticate using sasl protocol mechanism SCRAM-SHA-1. ---> MongoDB.Driver.MongoCommandException: Command saslStart failed: Authentication failed..\r\n at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1.ProcessReply(ConnectionId connectionId, ReplyMessage`1 reply)\r\n at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1.<ExecuteAsync>d_11.MoveNext()\r\n-- End of stack trace from previous location where exception was thrown --\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at MongoDB.Driver.Core.Authentication.SaslAuthenticator.<AuthenticateAsync>d7.MoveNext()\r\n — End of inner exception stack trace ---\r\n at MongoDB.Driver.Core.Authentication.SaslAuthenticator.<AuthenticateAsync>d_7.MoveNext()\r\n-- End of stack trace from previous location where exception was thrown ---\r\n at

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            raphael.londner Raphael Londner
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: