com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches PrimaryServerSelector. Client view of cluster state is {type=REPLICA_SET, servers=[{address=localhost:27017, type=REPLICA_SET_SECONDARY, roundTripTime=10.6 ms, state=CONNECTED}]

JIRA | Ratan Sebastian | 1 year ago
  1. 0

    I have a testing setup where I SSH tunnel from my local machine to a machine in a different VPC that hosts a mongo hidden secondary. It seems to be impossible to read from that secondary without given the driver access to the primary as well. I get the following exception when I try: {{ feature-dev 20:00:43.216 INFO org.mongodb.driver.cluster - Monitor thread successfully connected to server with description ServerDescription{address=localhost:27018, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 0, 2]}, minWireVersion=0, maxWireVersion=3, maxDocumentSize=16777216, roundTripTimeNanos=10440806} feature-dev 20:00:43.224 INFO org.mongodb.driver.cluster - Monitor thread successfully connected to server with description ServerDescription{address=localhost:27017, type=REPLICA_SET_SECONDARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 0, 4]}, minWireVersion=0, maxWireVersion=3, maxDocumentSize=16777216, roundTripTimeNanos=9489844, setName='mongo1', hosts=[10.0.0.126:27017, 10.0.0.124:27017, 10.0.0.125:27017], passives=[], arbiters=[], primary='10.0.0.124:27017', tagSet=TagSet{[]}} feature-dev[ERROR] com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches PrimaryServerSelector. Client view of cluster state is {type=REPLICA_SET, servers=[{address=localhost:27017, type=REPLICA_SET_SECONDARY, roundTripTime=10.6 ms, state=CONNECTED}] feature-dev[ERROR] at com.mongodb.connection.BaseCluster.createTimeoutException(BaseCluster.java:370) feature-dev[ERROR] at com.mongodb.connection.BaseCluster.selectServer(BaseCluster.java:101) feature-dev[ERROR] at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:75) feature-dev[ERROR] at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:71) feature-dev[ERROR] at com.mongodb.binding.ClusterBinding.getWriteConnectionSource(ClusterBinding.java:68) feature-dev[ERROR] at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:104) feature-dev[ERROR] at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:97) feature-dev[ERROR] at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:85) feature-dev[ERROR] at com.mongodb.operation.CommandWriteOperation.execute(CommandWriteOperation.java:55) feature-dev[ERROR] at com.mongodb.Mongo.execute(Mongo.java:745) feature-dev[ERROR] at com.mongodb.Mongo$2.execute(Mongo.java:728) feature-dev[ERROR] at com.mongodb.DB.executeCommand(DB.java:583) feature-dev[ERROR] at com.mongodb.DBCollection.getStats(DBCollection.java:1858) feature-dev[ERROR] at com.mongodb.hadoop.splitter.MongoSplitterFactory.getSplitterByStats(MongoSplitterFactory.java:73) feature-dev[ERROR] at com.mongodb.hadoop.splitter.MongoSplitterFactory.getSplitter(MongoSplitterFactory.java:113) ... }} (can send full stack trace if necessary. Unable to attach it) I'm able to read from the primary fine. Is this behaviour unavoidable? Can the driver not function without being able to query the primary for some reason? Do I need a testing setup that has access to both primary and hidden secondary?

    JIRA | 1 year ago | Ratan Sebastian
    com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches PrimaryServerSelector. Client view of cluster state is {type=REPLICA_SET, servers=[{address=localhost:27017, type=REPLICA_SET_SECONDARY, roundTripTime=10.6 ms, state=CONNECTED}]
  2. 0

    I have a testing setup where I SSH tunnel from my local machine to a machine in a different VPC that hosts a mongo hidden secondary. It seems to be impossible to read from that secondary without given the driver access to the primary as well. I get the following exception when I try: {{ feature-dev 20:00:43.216 INFO org.mongodb.driver.cluster - Monitor thread successfully connected to server with description ServerDescription{address=localhost:27018, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 0, 2]}, minWireVersion=0, maxWireVersion=3, maxDocumentSize=16777216, roundTripTimeNanos=10440806} feature-dev 20:00:43.224 INFO org.mongodb.driver.cluster - Monitor thread successfully connected to server with description ServerDescription{address=localhost:27017, type=REPLICA_SET_SECONDARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 0, 4]}, minWireVersion=0, maxWireVersion=3, maxDocumentSize=16777216, roundTripTimeNanos=9489844, setName='mongo1', hosts=[10.0.0.126:27017, 10.0.0.124:27017, 10.0.0.125:27017], passives=[], arbiters=[], primary='10.0.0.124:27017', tagSet=TagSet{[]}} feature-dev[ERROR] com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches PrimaryServerSelector. Client view of cluster state is {type=REPLICA_SET, servers=[{address=localhost:27017, type=REPLICA_SET_SECONDARY, roundTripTime=10.6 ms, state=CONNECTED}] feature-dev[ERROR] at com.mongodb.connection.BaseCluster.createTimeoutException(BaseCluster.java:370) feature-dev[ERROR] at com.mongodb.connection.BaseCluster.selectServer(BaseCluster.java:101) feature-dev[ERROR] at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:75) feature-dev[ERROR] at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:71) feature-dev[ERROR] at com.mongodb.binding.ClusterBinding.getWriteConnectionSource(ClusterBinding.java:68) feature-dev[ERROR] at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:104) feature-dev[ERROR] at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:97) feature-dev[ERROR] at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:85) feature-dev[ERROR] at com.mongodb.operation.CommandWriteOperation.execute(CommandWriteOperation.java:55) feature-dev[ERROR] at com.mongodb.Mongo.execute(Mongo.java:745) feature-dev[ERROR] at com.mongodb.Mongo$2.execute(Mongo.java:728) feature-dev[ERROR] at com.mongodb.DB.executeCommand(DB.java:583) feature-dev[ERROR] at com.mongodb.DBCollection.getStats(DBCollection.java:1858) feature-dev[ERROR] at com.mongodb.hadoop.splitter.MongoSplitterFactory.getSplitterByStats(MongoSplitterFactory.java:73) feature-dev[ERROR] at com.mongodb.hadoop.splitter.MongoSplitterFactory.getSplitter(MongoSplitterFactory.java:113) ... }} (can send full stack trace if necessary. Unable to attach it) I'm able to read from the primary fine. Is this behaviour unavoidable? Can the driver not function without being able to query the primary for some reason? Do I need a testing setup that has access to both primary and hidden secondary?

    JIRA | 1 year ago | Ratan Sebastian
    com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches PrimaryServerSelector. Client view of cluster state is {type=REPLICA_SET, servers=[{address=localhost:27017, type=REPLICA_SET_SECONDARY, roundTripTime=10.6 ms, state=CONNECTED}]
  3. 0

    Unable to load data from Mongodb to Pig

    Stack Overflow | 2 years ago
    com.mongodb.MongoException$Network: Exception opening the socket}, caused by {java.net.ConnectException: Connection refused}}]
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Not able to import the data into hive from mongodb using mongo-hadoop connector

    Stack Overflow | 4 months ago | Maddy
    java.io.IOException: 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=am0101.test.com:27101, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=null, userName='dmdbxcc_write', source='dxccdb01', password=<hidden>, mechanismProperties={}}}, caused by {com.mongodb.MongoCommandException: Command failed with error 18: 'Authentication failed.' on server am0101.test.com:27101. The full response is { "ok" : 0.0, "code" : 18, "errmsg" : "Authentication failed." }}}, {address=am0102.test.com:27101, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=null, userName='dmdbxcc_write', source='dxccdb01', password=<hidden>, mechanismProperties={}}}, caused by {com.mongodb.MongoCommandException: Command failed with error 18: 'Authentication failed.' on server am0102.test.com:27101. The full response is { "ok" : 0.0, "code" : 18, "errmsg" : "Authentication failed." }}}]
  6. 0

    Mongodb java client fails when Primary Server node changes in replicaset

    Stack Overflow | 5 months ago | Master Chief
    com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches PrimaryServerSelector. Client view of cluster state is {type=REPLICA_SET, servers=[{address=intdb01:27017, type=REPLICA_SET_SECONDARY, roundTripTime=0.7 ms, state=CONNECTED}]

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    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 PrimaryServerSelector. Client view of cluster state is {type=REPLICA_SET, servers=[{address=localhost:27017, type=REPLICA_SET_SECONDARY, roundTripTime=10.6 ms, state=CONNECTED}]

      at com.mongodb.connection.BaseCluster.createTimeoutException()
    2. MongoDB Java Driver
      DBCollection.getStats
      1. com.mongodb.connection.BaseCluster.createTimeoutException(BaseCluster.java:370)
      2. com.mongodb.connection.BaseCluster.selectServer(BaseCluster.java:101)
      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.getWriteConnectionSource(ClusterBinding.java:68)
      6. com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:104)
      7. com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:97)
      8. com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:85)
      9. com.mongodb.operation.CommandWriteOperation.execute(CommandWriteOperation.java:55)
      10. com.mongodb.Mongo.execute(Mongo.java:745)
      11. com.mongodb.Mongo$2.execute(Mongo.java:728)
      12. com.mongodb.DB.executeCommand(DB.java:583)
      13. com.mongodb.DBCollection.getStats(DBCollection.java:1858)
      13 frames
    3. com.mongodb.hadoop
      MongoSplitterFactory.getSplitter
      1. com.mongodb.hadoop.splitter.MongoSplitterFactory.getSplitterByStats(MongoSplitterFactory.java:73)
      2. com.mongodb.hadoop.splitter.MongoSplitterFactory.getSplitter(MongoSplitterFactory.java:113)
      2 frames