使用 CompositeServerSelector 选择服务器 30000 毫秒后发生超时 [英] A timeout occured after 30000ms selecting a server using CompositeServerSelector

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

问题描述

我尝试在 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:password@ds011111.mongolab.com:11111/db-name")

现在解决了.

请参阅 Paul Lemke 的回答.

Please see the answer from Paul Lemke.

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆