-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: 1.4
-
Component/s: None
I've noticed this when working with connections to replica sets; it may also affect connections to standalone mongo instances. If the driver's connection to a replica set is broken (such as if a minority of nodes are up and the primary steps down) and auto_reconnect is true, when the connection is reestablished, the socketTimeoutMS options seems to default to 30 seconds. I noticed this by looking at the mongod.log and saw that every 30 seconds, the connection was being destroyed and recreated; this wasn't happening before the connection was first broken and reestablished.
Normally this wouldn't concern me since the connection still worked after reconnecting, but I found that if my app tried to call the database during one of the periodic connection recreations, it would result in an error (since the connection was destroyed at the time).
Setting replSet.socketOptions.socketTimeoutMS = 0 in the options when first calling MongoClient.connect() didn't seem to help.