000ms使用CompositeServerSelector选择

000ms使用CompositeServerSelector选择

本文介绍了30000ms使用CompositeServerSelector选择服务器后发生超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在Mongolabs中部署我的Mongo数据库,一切正常,然后创建一个新数据库.请查看我的连接字符串.

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

    public DbHelper()
    {

        MongoClientSettings settings = new MongoClientSettings()
        {
            Credentials = new MongoCredential[] { MongoCredential.CreateCredential("dbname", "username", "password") },
            Server = new MongoServerAddress("ds011111.mongolab.com", 11111),
            //ConnectTimeout = new TimeSpan(30000)
        };

        Server = new MongoClient(settings).GetServer();

        DataBase = Server.GetDatabase(DatabaseName);

    }

但是当我尝试连接数据库时,它显示出如下错误:

but when I try to connect the database it's shows error like:

推荐答案

我正在如下替换连接字符串方法.

I am replacing the connection string method in like below.

new MongoClient("mongodb://username:[email protected]:11111/db-name")

现在解决了.

请参阅Paul Lemke的回答.

Please see the answer from Paul Lemke.

这篇关于30000ms使用CompositeServerSelector选择服务器后发生超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 15:54