MongoClient Timeout

I recently upgraded to MongoDB 2.6.3 via Ubuntu debs and also switched to Mongo Client library 2.12.2; when I'm doing now

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

      

then the "test" sysout is written, but the collectionExists () method timed out:

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)

      

I can connect to MongoDB using a client command line tool and query what I want with no problem.

+3


source to share





All Articles