com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=10.10.64.179:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]

GitHub | pthewizard | 6 months ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    Getting exception while connecting to mongodb using java code.

    GitHub | 6 months ago | pthewizard
    com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=10.10.64.179:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]
  2. 0

    ExtentX 1.0 with mongodb issue

    GitHub | 2 months ago | BTGBIMobile
    com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.SocketTimeoutException: connect timed out}}]
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

Root Cause Analysis

  1. com.mongodb.MongoTimeoutException

    Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=10.10.64.179:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]

    at com.mongodb.connection.BaseCluster.createTimeoutException()
  2. MongoDB Java Driver
    FindIterableImpl.first
    1. com.mongodb.connection.BaseCluster.createTimeoutException(BaseCluster.java:375)
    2. com.mongodb.connection.BaseCluster.selectServer(BaseCluster.java:104)
    3. com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:75)
    4. com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:71)
    5. com.mongodb.binding.ClusterBinding.getReadConnectionSource(ClusterBinding.java:63)
    6. com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:212)
    7. com.mongodb.operation.FindOperation.execute(FindOperation.java:483)
    8. com.mongodb.operation.FindOperation.execute(FindOperation.java:80)
    9. com.mongodb.Mongo.execute(Mongo.java:818)
    10. com.mongodb.Mongo$2.execute(Mongo.java:805)
    11. com.mongodb.FindIterableImpl$FindOperationIterable.first(FindIterableImpl.java:207)
    12. com.mongodb.FindIterableImpl.first(FindIterableImpl.java:148)
    12 frames
  3. com.relevantcodes.extentreports
    Report.attach
    1. com.relevantcodes.extentreports.reporter.ExtentXReporter.setupProject(ExtentXReporter.java:195)
    2. com.relevantcodes.extentreports.reporter.ExtentXReporter.start(ExtentXReporter.java:161)
    3. com.relevantcodes.extentreports.Report.attach(Report.java:38)
    3 frames
  4. Java RT
    ReferencePipeline$Head.forEach
    1. java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
    2. java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
    2 frames
  5. com.relevantcodes.extentreports
    ExtentReports.attachReporter
    1. com.relevantcodes.extentreports.ExtentReports.attachReporter(ExtentReports.java:11)
    1 frame
  6. Unknown
    ExtentReport.beforeTest
    1. ExtentReport.beforeTest(ExtentReport.java:61)
    1 frame
  7. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    4. java.lang.reflect.Method.invoke(Method.java:498)
    4 frames
  8. TestNG
    RemoteTestNG.main
    1. org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
    2. org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:514)
    3. org.testng.internal.Invoker.invokeConfigurations(Invoker.java:215)
    4. org.testng.internal.Invoker.invokeConfigurations(Invoker.java:142)
    5. org.testng.TestRunner.beforeRun(TestRunner.java:656)
    6. org.testng.TestRunner.run(TestRunner.java:624)
    7. org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
    8. org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
    9. org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
    10. org.testng.SuiteRunner.run(SuiteRunner.java:268)
    11. org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    12. org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    13. org.testng.TestNG.runSuitesSequentially(TestNG.java:1244)
    14. org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
    15. org.testng.TestNG.run(TestNG.java:1064)
    16. org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
    17. org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:152)
    18. org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:57)
    18 frames