Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-62093

Failing to connect to Atlas from C#

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • ALL

      We have a test Atlas database up and running.

      We can connect to it using Mongo Shell and list the collections from the database successfully.

      However, when we try and connect using C# (running the following code):

      var settings = MongoClientSettings.FromConnectionString("mongodb+srv://menadmin:<our password here>@cluster0.k2loi.mongodb.net/MAP?retryWrites=true&w=majority");
      var client = new MongoClient(settings);
      var dbList = client.ListDatabases().ToList();

      Where <our password here> is replaced by our password. Running this code gives this error:

      System.TimeoutException: 'A timeout occurred after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector

      { AllowedLatencyRange = 00:00:00.0150000 }

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

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

      ", EndPoint: "Unspecified/cluster0-shard-00-00.k2loi.mongodb.net:27017", ReasonChanged: "Heartbeat", State: "Disconnected", ServerVersion: , TopologyVersion: , Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server.
      ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (10060): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. 52.31.23.157:27017

      We are using version 2.14.1 of the C# Mongo drivers. It also fails using version 2.10.4 with the same error. We have also tried the code from a .NET framework application and a .NET core application with the same result.

      Do you have any idea what the issue could be?

       

            Assignee:
            Unassigned Unassigned
            Reporter:
            ihannah@meniscus.co.uk Ian Hannah
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: