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

System.TimeoutException: A timeout occured after 30000ms selecting a server using CompositeServerSelector

    • Type: Icon: Task Task
    • Resolution: Works as Designed
    • Priority: Icon: Critical - P2 Critical - P2
    • None
    • Affects Version/s: 2.2.4
    • Component/s: Connectivity
    • Labels:

      Hello, I have a .net core web application that gets some information from MongoDB replica set but from time to time I'm getting a timeout errors.
      I'm using a repository pattern and in mine IoC container (autofac) MongoDB repository is registered with InstancePerLifetimeScope.

      Connection String: mongodb://<first server name>,<second server name>,<third server name>/<database name>?replicaSet=rs0&connectTimeoutMS=30000

      MongoDB Driver version is 2.2.4
      MongoDB version is 3.0.7

      Error message is:
      Exception: System.TimeoutException Source: MongoDB.Driver.Core Message: A timeout occured after 30000ms selecting a server using CompositeServerSelector{
      Selectors = ReadPreferenceServerSelector{ ReadPreference =

      { Mode = Primary, TagSets = [] }

      }, LatencyLimitingServerSelector

      { AllowedLatencyRange = 00:00:00.0150000 }

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

      { ClusterId : 2, EndPoint : "Unspecified/<first server name>" }

      ", EndPoint: "Unspecified/<first server name>", State: "Disconnected", Type: "Unknown" },
      { ServerId: "

      { ClusterId : 2, EndPoint : "Unspecified/<second server name>" }

      ", EndPoint: "Unspecified/<second server name>", State: "Disconnected", Type: "Unknown" },
      { ServerId: "

      { ClusterId : 2, EndPoint : "Unspecified/<third server name>" }

      ", EndPoint: "Unspecified/<third server name>", State: "Disconnected", Type: "Unknown" }] }.

      Stack Trace Message:
      at MongoDB.Driver.Core.Clusters.Cluster.ThrowTimeoutException(IServerSelector selector, ClusterDescription description)
      at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChangedHelper.HandleCompletedTask(Task completedTask)
      at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChanged(IServerSelector selector, ClusterDescription description, Task descriptionChangedTask, TimeSpan timeout, CancellationToken cancellationToken)
      at MongoDB.Driver.Core.Clusters.Cluster.SelectServer(IServerSelector selector, CancellationToken cancellationToken)
      at MongoDB.Driver.Core.Bindings.ReadPreferenceBinding.GetReadChannelSource(CancellationToken cancellationToken)
      at MongoDB.Driver.Core.Operations.FindOperation`1.Execute(IReadBinding binding, CancellationToken cancellationToken)
      at MongoDB.Driver.OperationExecutor.ExecuteReadOperation[TResult](IReadBinding binding, IReadOperation`1 operation, CancellationToken cancellationToken)
      at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperation[TResult](IReadOperation`1 operation, ReadPreference readPreference, CancellationToken cancellationToken)
      at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperation[TResult](IReadOperation`1 operation, CancellationToken cancellationToken)
      at MongoDB.Driver.MongoCollectionImpl`1.FindSync[TProjection](FilterDefinition`1 filter, FindOptions`2 options, CancellationToken cancellationToken)
      at MongoDB.Driver.FindFluent`2.ToCursor(CancellationToken cancellationToken)
      at MongoDB.Driver.IAsyncCursorSourceExtensions.FirstOrDefault[TDocument](IAsyncCursorSource`1 source, CancellationToken cancellationToken)
      at MongoDB.Driver.IFindFluentExtensions.FirstOrDefault[TDocument,TProjection](IFindFluent`2 find, CancellationToken cancellationToken)

      To trace these errors I created a tool that periodically connects to MongoDB and logs connection state. According to these logs mongo was accessible at that point of time when one of these timeouts occurred so I'm pretty sure that it's not a network issue.

            Assignee:
            Unassigned Unassigned
            Reporter:
            Anton Hnatyshen Anton Hnatyshen
            Votes:
            16 Vote for this issue
            Watchers:
            40 Start watching this issue

              Created:
              Updated:
              Resolved: