[JAVA-1343] Proof of concept failed Created: 04/Aug/14  Updated: 05/Aug/14  Resolved: 04/Aug/14

Status: Closed
Project: Java Driver
Component/s: GridFS
Affects Version/s: 2.12.3
Fix Version/s: None

Type: Bug Priority: Blocker - P1
Reporter: Jyoti Das Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Mongodb in Linux, application on Windows 7



 Description   

Exception in thread "main" com.mongodb.MongoTimeoutException: Timed out while waiting for a server that matches AnyServerSelector{} after 10000 ms
    at com.mongodb.BaseCluster.getServer(BaseCluster.java:87)
    at com.mongodb.DBTCPConnector.getServer(DBTCPConnector.java:654)
    at com.mongodb.DBTCPConnector.access$300(DBTCPConnector.java:39)
    at com.mongodb.DBTCPConnector$MyPort.getConnection(DBTCPConnector.java:503)
    at com.mongodb.DBTCPConnector$MyPort.get(DBTCPConnector.java:451)
    at com.mongodb.DBTCPConnector.getPrimaryPort(DBTCPConnector.java:409)
    at com.mongodb.DBCollectionImpl.insert(DBCollectionImpl.java:182)
    at com.mongodb.DBCollectionImpl.insert(DBCollectionImpl.java:165)
    at com.mongodb.DBCollection.insert(DBCollection.java:161)
    at com.mongodb.DBCollection.insert(DBCollection.java:107)
    at com.mongodb.DBCollection.save(DBCollection.java:966)
    at com.mongodb.DBCollection.save(DBCollection.java:934)
    at com.mongodb.gridfs.GridFSInputFile._dumpBuffer(GridFSInputFile.java:281)
    at com.mongodb.gridfs.GridFSInputFile.saveChunks(GridFSInputFile.java:231)
    at com.mongodb.gridfs.GridFSInputFile.save(GridFSInputFile.java:177)
    at com.mongodb.gridfs.GridFSInputFile.save(GridFSInputFile.java:158)
    at es.db.mongodb.MongodbTest.main(MongodbTest.java:76)

The code:

public class MongodbTest {
     
     
    public static void main(String[] args) throws IOException {
 
 
        System.out.println("Entered mongotest");       
        MongoClient mongoClient = new MongoClient("192.168.1.214", 27017);
           
        //http://api.mongodb.org/java/2.10.1/com/mongodb/MongoClient.html
        //A MongoDB client with internal connection pooling. For most applications,
        //you should have one MongoClient instance for the entire JVM.   
       
        DB db = mongoClient.getDB("test");
       
        DBCollection collection = db.getCollection("downloads_meta");
 
        String filePath = "C:\\axd\\dell_fig1.jpg";
        File file = new File(filePath);
 
        GridFS gridfs = new GridFS(db, "downloads");
        GridFSInputFile gfsFile = gridfs.createFile(file);
        gfsFile.setFilename("dell_fig1.jpg");
        gfsFile.save();  //It crashes here.
 
 
        BasicDBObject info = new BasicDBObject();
                info.put("name", "Dell");
                info.put("fileName", "dell_fig1.jpg");
                info.put("rawName", "dell_fig1.jpg");
                info.put("rawPath", "C:\\axd");
 
        collection.insert(info, WriteConcern.SAFE);
    }   
}



 Comments   
Comment by Jyoti Das [ 04/Aug/14 ]

Hi Jeff,

It works now. The issue with the default yum install is that the server is only listening to local IP. I commented out

bind_ip = 127.0.0.1

now it works.

Please update the install scripts or documentation and close this case.

Thanks.

Jyoti Das

EcoSuite Corporation
www.ecosuite.com
Tel: (561) 303-9695

Comment by Jeffrey Yemin [ 04/Aug/14 ]

Hi Jyoti,

You might have a look at http://docs.mongodb.org/manual/administration/configuration/#security-considerations, in particular the section about bind_ip, as it sounds like mongod is not binding to the IP address that your client is connecting to.

If that doesn't help, please follow up with additional questions on our public user forum: https://groups.google.com/forum/#!forum/mongodb-user. As this project is intended for reporting issues with the MongoDB Java driver, it's not really the right forum for addressing this issue, which is almost certainly network-related.

Comment by Jyoti Das [ 04/Aug/14 ]

Hi Jeff,

telnet cannot connect to port 27017. This means that nobody is listening on that port. Is there something that we should install or configure?

Thanks.

Jyoti Das

EcoSuite Corporation
www.ecosuite.com
Tel: (561) 303-9695

Comment by Jyoti Das [ 04/Aug/14 ]

Hi Jeff,

The mongodb version is 2.6.3. The jave driver version we have is the latest one from your site (2.12.13).

We also turned off iptables so that connecting is not an issue.

From the app, we should have throws exception is it could not have connected from any of the previous statement. But, it throws exception from gfsFile.save();

MongoClient mongoClient = new MongoClient("192.168.1.214", 27017);
DB db = mongoClient.getDB("test");
DBCollection collection = db.getCollection("downloads_meta");

On the server where mongodb is installed nmap does not show that anybody is listening to port 27017. But I can invoke
mongo and see the "test" database.

From the development computer on a Windows 7 machine (Eclipse), I do not have telnet installed. I will try that later.

Thanks.

Jyoti

Jyoti Das

EcoSuite Corporation
www.ecosuite.com
Tel: (561) 303-9695

Comment by Jeffrey Yemin [ 04/Aug/14 ]

Are you able to ping 192.168.1.214 on the server you're running this test on? If so, can you telnet to port 27017? If so, are you able to connect using the mongo shell?

Also, can you try with the latest version of the driver, which is 2.12.3? 2.6.3 is a very old version of the driver.

Generated at Thu Feb 08 08:54:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.