MongoClient超时

时间:2014-08-15 05:54:11

标签: java mongodb timeout mongo-java

我最近通过Ubuntu debs更新到MongoDB 2.6.3,并切换到Mongo Client库2.12.2;当我现在执行

    final MongoClient m = new MongoClient( "localhost" );
    DB db = m.getDB( "test" );
    System.out.println( db.getName( ) );
    System.out.println( db.collectionExists( "Customer" ) );

然后编写“test”sysout,但在collectionExists()方法期间发生超时:

Exception in thread "main" com.mongodb.MongoTimeoutException: Timed out while waiting to connect after 4996 ms
at com.mongodb.BaseCluster.getDescription(BaseCluster.java:114)
at com.mongodb.DBTCPConnector.getClusterDescription(DBTCPConnector.java:396)
at com.mongodb.DBTCPConnector.getMaxBsonObjectSize(DBTCPConnector.java:641)
at com.mongodb.Mongo.getMaxBsonObjectSize(Mongo.java:641)
at com.mongodb.DBCollectionImpl.find(DBCollectionImpl.java:81)
at com.mongodb.DBCollectionImpl.find(DBCollectionImpl.java:66)
at com.mongodb.DB.getCollectionNames(DB.java:510)
at com.mongodb.DB.collectionExists(DB.java:553)
at com.apiomat.backend.persistence.MongoFacade.main(MongoFacade.java:342)

我可以通过命令行客户端工具连接到MongoDB并查询我想要的内容而不会出现问题。

0 个答案:

没有答案