-
Type:
Bug
-
Resolution: Done
-
Priority:
Major - P3
-
None
-
Affects Version/s: 2.0
-
Component/s: Connectivity
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Repro:
In a replication set, mongodb service is listening with hostname(which resolves to a private IP in a virtual network).
From client side, the seed list is composed of public DNS names.
then C# driver fails to connect, with below error:
Error:
at MongoDB.Driver.Core.Servers.ClusterableServer.<HeartbeatAsync>d__d.MoveNext()" }, { ServerId: "{ ClusterId : 1, EndPoint : {color:red}"Unspecified/vmsec0521e:27000"{color} }", EndPoint: "Unspecified/vmsec0521e:27000", State: "Disconnected", Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server. ---> System.Net.Sockets.SocketException: No such host is known
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
Code:
var cnnString = "mongodb://<userName>:<pwd>@vmpri0521e.westus.cloudapp.azure.com:27000, {color:red}vmsec0521e.westus.cloudapp.azure.com:27000{color}/testoc?replicaSet=rs0521e";
var client = new MongoClient(cnnString);
var db = client.GetDatabase("testoc");
var col = db.GetCollection<Post>("Posts");
var posts = await col.Find(e => true).ToListAsync();
rs.conf information
rs0521e:PRIMARY> rs.conf()
{
"_id" : "rs0521e",
"version" : 7,
"members" : [
{
"_id" : 0,
"host" : "vmpri0521e:27000",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 5,
"tags" : {
},
"slaveDelay" : 0,
"votes" : 1
},
{
"_id" : 1,
"host" : "vmsec0521e:27000",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {
},
"slaveDelay" : 0,
"votes" : 1
},
{
"_id" : 2,
"host" : "vmarb0521e:27000",
"arbiterOnly" : true,
"buildIndexes" : true,
"hidden" : false,
"priority" : 0,
"tags" : {
},
"slaveDelay" : 0,
"votes" : 1
}
],
"settings" : {
"chainingAllowed" : true,
"heartbeatTimeoutSecs" : 10,
"getLastErrorModes" : {
},
"getLastErrorDefaults" : {
"w" : 1,
"wtimeout" : 0
}
}
}
rs.status information:
rs0521e:PRIMARY> rs.status()
{
"set" : "rs0521e",
"date" : ISODate("2015-05-22T18:18:20.610Z"),
"myState" : 1,
"members" : [
{
"_id" : 0,
"name" : "vmpri0521e:27000",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 10942,
"optime" : Timestamp(1432308408, 1),
"optimeDate" : ISODate("2015-05-22T15:26:48Z"),
"electionTime" : Timestamp(1432307801, 1),
"electionDate" : ISODate("2015-05-22T15:16:41Z"),
"configVersion" : 7,
"self" : true
},
{
"_id" : 1,
"name" : "vmsec0521e:27000",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 10292,
"optime" : Timestamp(1432308408, 1),
"optimeDate" : ISODate("2015-05-22T15:26:48Z"),
"lastHeartbeat" : ISODate("2015-05-22T18:18:20.351Z"),
"lastHeartbeatRecv" : ISODate("2015-05-22T18:18:19.195Z"),
"pingMs" : 1,
"configVersion" : 7
},
{
"_id" : 2,
"name" : "vmarb0521e:27000",
"health" : 1,
"state" : 7,
"stateStr" : "ARBITER",
"uptime" : 10292,
"lastHeartbeat" : ISODate("2015-05-22T18:18:20.026Z"),
"lastHeartbeatRecv" : ISODate("2015-05-22T18:18:18.991Z"),
"pingMs" : 1,
"configVersion" : 7
}
],
"ok" : 1
}
More Information:
Not repro in NodeJs driver with same connection string. So looks like this is a C# driver issue.