Timeout connecting to MongoDB 3.2

452 views
Skip to first unread message

Tiago Santos

unread,
Aug 29, 2016, 10:50:58 AM8/29/16
to mongodb-user
Hi,

I'm using .NET Driver version 2.2.4 (application using .NET 4.5) to connect to MongoDB version 3.2 and i'm receiving some timeout exceptions, that I can't understand why.

Scenario detail: 

We have a ReplicaSet with 2 servers, and one of the servers also have a arbiter running at port 27018. The application that is connecting, runs in two servers (A and B) with Windows Server 2008 R2. In server A all connections and requests work perfectly, but in server B, the first connection throws a timeout exception with the follow error message:

A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = ReadPreferenceServerSelector{ ReadPreference = { Mode = Primary, TagSets = [] } }, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:01 } }. Client view of cluster state is { ClusterId : "5", ConnectionMode : "ReplicaSet", Type : "ReplicaSet", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 5, EndPoint : "Unspecified/serverA.domain:27017" }", EndPoint: "Unspecified/serverA.domain:27017", State: "Disconnected", Type: "Unknown" }, { ServerId: "{ ClusterId : 5, EndPoint : "Unspecified/serverB.domain:27017" }", EndPoint: "Unspecified/serverB.domain:27017", State: "Disconnected", Type: "Unknown" }] }.

Does someone already seen this behavior?

Thanks

Tiago Santos

unread,
Aug 30, 2016, 4:32:43 PM8/30/16
to mongodb-user
This problem was happening because the driver was taking more than 30000ms to Select the Server. 

After increase the SeverSelectTimeout we connected without problems. 

Dows someone knows how the C# MongoDb Driver discover if a sever is Disconnected ou Connected? I'm asking because one of my servers does this very fast, and the other take more than 30 seconds. 

Even solving the problem increasing the SeverSelectTimeout, we're looking for the reason of the driver take too many time to select the server.

John Murphy

unread,
Sep 7, 2016, 11:56:50 PM9/7/16
to mongodb-user

Hi Tiago,

Dows someone knows how the C# MongoDb Driver discover if a sever is Disconnected ou Connected? I’m asking because one of my servers does this very fast, and the other take more than 30 seconds.

The C# Driver Core documentation outlines at a high level how Server Discovery and Monitoring takes place. Essentially the driver will connect to each host in the seed list and issue an isMaster command.

Considering that one application server works while the other doesn’t, could you please confirm that both servers have the same networking configuration and use an identical connection string? If possible could you include an example of the string you are using.

Regards,
John Murphy

Reply all
Reply to author
Forward
0 new messages