title: Can not connector to replica set with Java driver, works with Node.js driver
body: <p>Here is how I connect to my replica set with Node.js:</p>
  
  <pre><code>var MongoClient = require('mongodb').MongoClient;
  
  var url = 'mongodb://ec2-54-237-60-17.compute-1.amazonaws.com:27017/test?readPreference=secondary';
  
  MongoClient.connect(url, function(err, db) {
      console.log(err);
  
      db.collection('apps').find({}).limit(5).toArray(function(err, docs) {
          console.log(docs);
      });
  });
  </code></pre>
  
  <p>and I get <code>5</code> in the console so it works correctly.
  With the Java driver here is what I do:</p>
  
  <pre><code>import com.mongodb.MongoClient
  import com.mongodb.MongoClientURI
  import java.util.ArrayList
  import com.mongodb.BasicDBObject
  
  object Main extends App {
      val url = "mongodb://ec2-54-237-60-17.compute-1.amazonaws.com:27017/test?readPreference=secondary"
      val client = new MongoClient(new MongoClientURI(url))
  
      val db = client.getDatabase("database")
      val collection = db.getCollection("apps")
      val results = collection.find().limit(5).into(new ArrayList[org.bson.Document]())
  }
  </code></pre>
  
  <p>and I get the following exception:</p>
  
  <pre><code>com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=secondary}. Client view of cluster state is {type=REPLICA_SET, servers=[{address=belinda-mongo.localdomain:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketException: belinda-mongo.localdomain}, caused by {java.net.UnknownHostException: belinda-mongo.localdomain}}, {address=detroit-mongo.localdomain:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketException: detroit-mongo.localdomain}, caused by {java.net.UnknownHostException: detroit-mongo.localdomain}}, {address=dione-mongoar.localdomain:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketException: dione-mongoar.localdomain}, caused by {java.net.UnknownHostException: dione-mongoar.localdomain}}, {address=pandora-mongo.localdomain:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketException: pandora-mongo.localdomain}, caused by {java.net.UnknownHostException: pandora-mongo.localdomain}}, {address=riverside-mongo.localdomain:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketException: riverside-mongo.localdomain}, caused by {java.net.UnknownHostException: riverside-mongo.localdomain}}]
  com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=secondary}. Client view of cluster state is {type=REPLICA_SET, servers=[{address=belinda-mongo.localdomain:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketException: belinda-mongo.localdomain}, caused by {java.net.UnknownHostException: belinda-mongo.localdomain}}, {address=detroit-mongo.localdomain:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketException: detroit-mongo.localdomain}, caused by {java.net.UnknownHostException: detroit-mongo.localdomain}}, {address=dione-mongoar.localdomain:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketException: dione-mongoar.localdomain}, caused by {java.net.UnknownHostException: dione-mongoar.localdomain}}, {address=pandora-mongo.localdomain:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketException: pandora-mongo.localdomain}, caused by {java.net.UnknownHostException: pandora-mongo.localdomain}}, {address=riverside-mongo.localdomain:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketException: riverside-mongo.localdomain}, caused by {java.net.UnknownHostException: riverside-mongo.localdomain}}]
  </code></pre>
  
  <p>I have no idea why it's working with one driver but no the other.</p>
  
  <p>Edit: When I'm trying to connect only to the primary node with the following url <code>mongodb://login:pwd@host:27019/database</code> it works, it fails only when I add the second one.</p>