A timeout occured after 30000ms selecting a server using CompositeServerSelector

前端 未结 9 1748
南方客
南方客 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 08:14

    Add "?connect=replicaSet" to the end of your connection string if connecting to MongoLab.

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

    This JIRA ticket has some details: https://jira.mongodb.org/browse/CSHARP-1160

    Basically the default is to connect to a replica set member. But MongoLab's Single-Node settings are actually a single node replica set and this causes us to not trust it. Appending ?connect=replicaSet to your connection string will force the driver to move into replica set mode and all will work.

    Found that info here.

提交回复
热议问题