The MongoConnectionException class
Introduction
Thrown when the driver fails to connect to the database.
There are a number of possible error messages to help you diagnose the connection problem. These are:
-
No server name given.
This error occurs if you pass in "" as the server name, probably because of an typo with string interpolation, e.g., "$servr" instead of "$server".
-
failed to get left host [hostname] or port [portnum] from [server].
failed to get right host [hostname] or port [portnum] from [server].
This indicated that the first or second server respectively in a "server1,server2" connection string was malformed. "[hostname]" and "[portnum]" will be as much as the driver could dicipher of it.
-
failed to get host [hostname] or port [portnum] from [server].
This indicated that the server string was malformed. "[hostname]" and "[portnum]" will be as much as the driver could dicipher of it.
-
paired connection, but no right host given
The user attempted to create a paired connection but passed a string that only listed one server to connect to.
-
Operation in progress
Connecting to the database timed out.
-
More links than your body has room for: N of M
N is the number of open connections and M is the maximum number of connections allowed. By default, the driver allows unlimited simultaneous connections to the database. If you wish to limit them, you can set mongo.max_connections and/or mongo.max_persistent (for limiting perisistent connections). If you try to create more than that number of connections, you will get this error.
-
couldn't determine master
Neither server in a paired connection appeared to be master.
-
couldn't get host info for [server]
This indicated that DNS could not resolve the server address you gave. This could easily be caused by a typo, for example, "server" instead of "$server".
If the error message is not listed above, it is probably an error from the C socket, and you can search the web for its usual cause.
Class synopsis
MongoConnectionException
