1

我有一个安装了 64 位 Mongodb 的远程服务器并让 mongod 运行。我正在测试从家里连接它。使用以下连接字符串 C#:

connectionString = "mongodb://Administrator:mypassword@x.x.x.x:27017"

连接失败并出现以下错误:

Unable to connect to server x.x.x.x:27017: 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 x.x.x.x:27017

我需要在我的服务器上进行配置吗?还是在我的连接字符串中?

4

2 回答 2

0

我已经通过绑定解决了这个问题

bind_ip = 0.0.0.0
于 2015-06-17T18:47:04.297 回答
0

我也无法使用连接字符串连接到远程 MongoDB。我让它工作的方式有点冗长,但假设你试图这样做

var client = new MongoClient(connectionString);

那么这可以代替:

var client = new MongoClient(
new MongoClientSettings
{
 Credentials = new[]
 {
   MongoCredential.CreateCredential("Databasename","Administrator", "mypassword")
 },
 Server = new MongoServerAddress("x.x.x.x", 27017)
});
于 2015-08-04T19:11:37.043 回答