Ticket: Database Connection error com.mongodb.MongoTimeoutException

spring.mongodb.uri=mongodb+srv://m220student:m220password@mflix.7tuzs.mongodb.net/?maxPoolSize=50&connectTimeoutMS=2000
spring.mongodb.database=mflix

While I’m able connect to the database through compass with this uri, but in project in connection test it gives timeout exception. Every test is failing. I tried changing the database name from sample_mflix to mflix but still no luck. Any body can help me around please

com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches com.mongodb.client.internal.MongoClientDelegate$1@86d6bf7. Client view of cluster state is {type=REPLICA_SET, servers=[{address=mflix-shard-00-02.7tuzs.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketWriteException: Exception sending message}, caused by {javax.net.ssl.SSLHandshakeException: extension (5) should not be presented in certificate_request}}, {address=mflix-shard-00-01.7tuzs.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketWriteException: Exception sending message}, caused by {javax.net.ssl.SSLHandshakeException: extension (5) should not be presented in certificate_request}}, {address=mflix-shard-00-00.7tuzs.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketWriteException: Exception sending message}, caused by {javax.net.ssl.SSLHandshakeException: extension (5) should not be presented in certificate_request}}]
 at com.mongodb.internal.connection.BaseCluster.createTimeoutException(BaseCluster.java:401)
 at com.mongodb.internal.connection.BaseCluster.selectServer(BaseCluster.java:120)
 at com.mongodb.internal.connection.MultiServerCluster.selectServer(MultiServerCluster.java:54)
 at com.mongodb.client.internal.MongoClientDelegate.getConnectedClusterDescription(MongoClientDelegate.java:138)
 at com.mongodb.client.internal.MongoClientDelegate.createClientSession(MongoClientDelegate.java:94)
 at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.getClientSession(MongoClientDelegate.java:249)
 at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:172)
 at com.mongodb.client.internal.MongoCollectionImpl.executeCount(MongoCollectionImpl.java:248)
 at com.mongodb.client.internal.MongoCollectionImpl.countDocuments(MongoCollectionImpl.java:217)
 at com.mongodb.client.internal.MongoCollectionImpl.countDocuments(MongoCollectionImpl.java:212)
 at com.mongodb.client.internal.MongoCollectionImpl.countDocuments(MongoCollectionImpl.java:207)
 at mflix.api.daos.MovieDao.getMoviesCount(MovieDao.java:305)
 at mflix.api.daos.ConnectionTest.testMoviesCount(ConnectionTest.java:44)
 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.base/java.lang.reflect.Method.invoke(Method.java:567)
 at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
 at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
 at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:73)
 at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:83)
 at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
 at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
 at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
 at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
 at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
 at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
 at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
 at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
 at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
 at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
 at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
jwtSecret=SUPER_SECRET_KEY_YOU_WANT_TO_REPLACE_THIS
jwtExpirationInMs=604800000
spring.mongodb.uri=mongodb+srv://m220student:m220password@mflix.7tuzs.mongodb.net/test
spring.mongodb.database=mflix
server.port=5000
server.error.whitelabel.enabled=false
logging.level.api.controllers=DEBUG
api.movies.movies_per_page=20
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/build

Still not working

It sounds a lot like SSLHandshakeException : should not be presented in certificate_request. It’s likely due to a JDK bug which is fixed in more recent JDK releases.

2 Likes

I’m using jdk-17. I think it’s latest.
Any suggestions how to fix it @Jeffrey_Yemin

There’s a workaround offered there as well: force use of TLS 1.2. Have you tried that?

Otherwise, I’m unsure what to try next.

How do I put it, in which file

Hi @abhishek_sahoo,

Are you still facing the same issue or it has been resolved? Can you please update the current status of the problem!

Thanks,
Kushagra

yes, before running Handling timeout ticket, all tests including lessons were running fine. but now even Lessons are giving MongoTimeoutException: error