MongoClient m = new MongoClient(new ServerAddress("182.178.0.29",27017),
Arrays.asList(MongoCredential.createCredential("username", "employeedb", "password".toCharArray())));
MongoDatabase md = m.getDatabase("employeedb");
MongoIterable<String> strings = md.listCollectionNames();
MongoCursor<String> iterator = strings.iterator();
After authentication i need to show message to end user. But, the exception is comming after 30 seconds in case when the user enters wrong credentials.User needs to wait untill the msg dialog comes. Could you please check why it is taking that much time and is there any other way to authenticate.
MongoDB version: 3.2.14 java driver version: 3.2.1
Exception:
com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector