A timeout occured after 30000ms selecting a server using CompositeServerSelector

前端 未结 9 1701
南方客
南方客 2020-11-27 07:39

I try to deploy my Mongo database in Mongolabs, everything works fine, and I create a new database. Please see my connectionstring.

    public DbHelper()
            


        
相关标签:
9条回答
  • 2020-11-27 07:53

    Make sure your current ip address is white-listed in mongo db server. If you change your internet provider new IP needs to be white-listed.

    0 讨论(0)
  • 2020-11-27 07:55

    I had the same issue. I was able to connect to MongoDB Atlas Using MongoDb Compass, but using the same connection string in a C# project I got the error "A timeout occured after 30000ms selecting a server using CompositeServerSelector... ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (61): Connection refused 192.168.1.254:53".

    In my case the problem was caused by my Internet provider router. Switching the connection to my iPhone's 4G hotspot solved the connection issue.

    0 讨论(0)
  • 2020-11-27 07:57

    It's related with MongoDB connection error. Probably you don't have permissions or you didn't specify the allowed IPs in MongoDB. Please check for example in MongoDB Compose if you are able to connect with your MongoDB Atlas. If you won't be able to connect, that means that you have wrong MongoDB connection string.

    0 讨论(0)
  • 2020-11-27 07:58

    I had this issue and turned out the database server was 2 hours behind. Once I fixed its time, the timeout issue was resolved with it.

    0 讨论(0)
  • 2020-11-27 08:03

    I am replacing the connection string method in like below.

    new MongoClient("mongodb://username:password@ds011111.mongolab.com:11111/db-name")
    

    Now it's solved.

    Please see the answer from Paul Lemke.

    0 讨论(0)
  • 2020-11-27 08:03

    Make Sure your auth db is set correctly.

    I ran into this issue when I mentioned only the DB i wanted to connect to , and my auth db was different (other than admin db ).

    The db-name in this line is considered as the auth DB .

    new MongoClient("mongodb://username:password@ds011111.mongolab.com:11111/db-name?connect=replicaSet")
    

    Then you can change the selected DB Later

    mDb = mClient.GetDatabase(mongoDBName);
    
    0 讨论(0)
提交回复
热议问题