Contrary to the mongo documentation, the mongo::DBClientConnection::query method can throw a SocketException, change the try clause to catch this too