Connection Pooling / Handling Timeout - The return from the api was incorrect

Hi,
for this course I did’nt use Atlas for DB connection, but I imported the db locally with mongorestore to localhost. I’ve set correctly the connection string in application.properties with these parameters:

maxPoolSize=50&wtimeoutms=2500&connectTimeoutMS=2000

both tests pass successfully, but in the status page in “Connection Pooling” and “Handling Timeout” I have this error: “The return from the api was incorrect”.

What I can do for these tickets?

Hi @Demone,

Did you enabled authorization in your MongoDB localhost deployment ?
The all course validation assumes that you are using an set of username and credentials, given that those are security best practices, and that there is no way to avoid it in Atlas.

If you are not, please do enable auth and set the credentials in your MongoDB connection string.

That is the reason why you are not validating this lab. Also, you need it for the upcoming labs.

N.

1 Like

Thanks a lot, I completed all my tickets :wink:

PS: I use passwordDigestor: “server” option in db.createUser command, because SCRAM-SHA-256 requires undigested passwords and it raise an error

Regards,
Francesco

I’ve made appropriate changes to MongoDBConfiguration:

ConnectionString connString = new ConnectionString(connectionString);
MongoClientSettings settings = MongoClientSettings.builder()
.writeConcern(WriteConcern.MAJORITY.withWTimeout(2500, TimeUnit.MILLISECONDS))
.applyConnectionString(connString).build();
MongoClient mongoClient = MongoClients.create(settings);

and to url:
mongodb+srv://m220student:m220password@mflix-kixd8.mongodb.net/?maxPoolSize=50&connectTimeoutMS=2000

The ConnectionPoolingTest and TimeoutsTest are passing. But I get this message for both validation on status page:

“The return from the api was incorrect”

What have I missed / done wrong?

Thanks for sharing the code.
Can you please try re-arranging this code? Or maybe appending wtimeout=2500 in the url ?

MongoClientSettings settings = MongoClientSettings.builder()
.applyConnectionString(connString)
.writeConcern(WriteConcern.MAJORITY.withWTimeout(2500, TimeUnit.MILLISECONDS))
.build();

Let me know if it works.

Kanika