java.io.IOException: couldn't connect to [ip-10-166-59-166/10.166.59.166:20000] bc:java.net.ConnectException: Connection refused

JIRA | Joseph Wang | 7 years ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    Have the following codes: try { db = mongo.getDb("lp"); coll = db.getCollection("lp.mrtest"); if (enable_limit) { cur = coll.find(query).limit(20).addOption( Bytes.QUERYOPTION_SLAVEOK); } else { cur = coll.find(query).addOption(Bytes.QUERYOPTION_SLAVEOK); } size = enable_limit ? cur.itcount() : cur.size(); } catch (Exception ex) { System.out.println("count: get exception " + ex); ex.printStackTrace(); db = mongo.getDb("lp"); coll = db.getCollection("lp.mrtest"); if (enable_limit) { cur = coll.find(query).limit(20).addOption( Bytes.QUERYOPTION_SLAVEOK); } else { cur = coll.find(query).addOption(Bytes.QUERYOPTION_SLAVEOK); } size = enable_limit ? cur.itcount() : cur.size(); System.out.println("count: get " + size); } catch (Throwable t) { System.out.println("count: get thowable " + t); t.printStackTrace(); db = mongo.getDb("lp"); coll = db.getCollection("lp.mrtest"); if (enable_limit) { cur = coll.find(query).limit(20).addOption( Bytes.QUERYOPTION_SLAVEOK); } else { cur = coll.find(query).addOption(Bytes.QUERYOPTION_SLAVEOK); } size = enable_limit ? cur.itcount() : cur.size(); System.out.println("count: get " + size); } Testing failover by issuing kill -9 on the primary node. Cannot seem to be able to catch exception s.t. I can retry the query. java.io.IOException: couldn't connect to [ip-10-166-59-166/10.166.59.166:20000] bc:java.net.ConnectException: Connection refused at com.mongodb.DBPort._open(DBPort.java:205) at com.mongodb.DBPort.go(DBPort.java:85) at com.mongodb.DBPort.go(DBPort.java:66) at com.mongodb.DBPort.call(DBPort.java:56) at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:211) at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:284) at com.mongodb.DBCursor._check(DBCursor.java:297) at com.mongodb.DBCursor._hasNext(DBCursor.java:420) at com.mongodb.DBCursor.hasNext(DBCursor.java:445) at com.mongodb.DBCursor.itcount(DBCursor.java:535) at com.leadpoint.db.MongoDbQueryPerformanceTest.getCount(MongoDbQueryPerformanceTest.java:101) at com.leadpoint.db.MongoDbQueryPerformanceTest.main(MongoDbQueryPerformanceTest.java:255) Nov 4, 2010 4:03:26 PM com.mongodb.DBTCPConnector$MyPort error SEVERE: MyPort.error called java.io.IOException: couldn't connect to [ip-10-166-59-166/10.166.59.166:20000] bc:java.net.ConnectException: Connection refused at com.mongodb.DBPort._open(DBPort.java:205) at com.mongodb.DBPort.go(DBPort.java:85) at com.mongodb.DBPort.go(DBPort.java:66) at com.mongodb.DBPort.call(DBPort.java:56) at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:211) at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:284) at com.mongodb.DBCursor._check(DBCursor.java:297) at com.mongodb.DBCursor._hasNext(DBCursor.java:420) at com.mongodb.DBCursor.hasNext(DBCursor.java:445) at com.mongodb.DBCursor.itcount(DBCursor.java:535)

    JIRA | 7 years ago | Joseph Wang
    java.io.IOException: couldn't connect to [ip-10-166-59-166/10.166.59.166:20000] bc:java.net.ConnectException: Connection refused

    Root Cause Analysis

    1. java.io.IOException

      couldn't connect to [ip-10-166-59-166/10.166.59.166:20000] bc:java.net.ConnectException: Connection refused

      at com.mongodb.DBPort._open()
    2. MongoDB Java Driver
      DBCursor.itcount
      1. com.mongodb.DBPort._open(DBPort.java:205)
      2. com.mongodb.DBPort.go(DBPort.java:85)
      3. com.mongodb.DBPort.go(DBPort.java:66)
      4. com.mongodb.DBPort.call(DBPort.java:56)
      5. com.mongodb.DBTCPConnector.call(DBTCPConnector.java:211)
      6. com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:284)
      7. com.mongodb.DBCursor._check(DBCursor.java:297)
      8. com.mongodb.DBCursor._hasNext(DBCursor.java:420)
      9. com.mongodb.DBCursor.hasNext(DBCursor.java:445)
      10. com.mongodb.DBCursor.itcount(DBCursor.java:535)
      10 frames