Currently, attempting to establish a connection to a server will block for connectTimeoutMS, potentially exceeding the overall timeout of serverSelectionTimeoutMS. This causes some surprising behavior. For example the following connection attempt blocks for 5 seconds:
example-client "mongodb://1.1.1.1:12345/?serverSelectionTryOnce=false&serverSelectionTimeoutMS=1000&connectTimeoutMS=5000"
Strictly speaking, this might be compliant with the server selection spec:
Because single-threaded selection can do a blocking immediate check, serverSelectionTimeoutMS is not a hard deadline. The actual maximum server selection time for any given request can vary from serverSelectionTimeoutMS minus minHeartbeatFrequencyMS to serverSelectionTimeoutMS plus the time required for a blocking scan.
But libmongoc does not make a blocking connection, even for single threaded clients, and should be able to cap the timeout of connecting (probably here).