Exception information
December 22, 2014 5:27:58 pm Com.mongodb.DBTCPConnector initdirectconnection
Warning: Exception executing ismaster command on/192.168.1.249:10003
Java.io.IOException:couldn ' t connect to [/192.168.1.249:10003] Bc:java.net.SocketTimeoutException:connect timed out
At Com.mongodb.dbport._open (dbport.java:214)
At Com.mongodb.DBPort.go (dbport.java:107)
At Com.mongodb.DBPort.go (dbport.java:88)
At Com.mongodb.DBPort.findOne (dbport.java:143)
At Com.mongodb.DBPort.runCommand (dbport.java:148)
At Com.mongodb.DBTCPConnector.initDirectConnection (dbtcpconnector.java:539)
At Com.mongodb.Mongo.getMaxBsonObjectSize (mongo.java:600)
At Com.mongodb.dbapilayer$mycollection.insert (dbapilayer.java:233)
At Com.mongodb.dbapilayer$mycollection.insert (dbapilayer.java:205)
At Com.mongodb.DBCollection.insert (dbcollection.java:57)
At Com.mongodb.DBCollection.insert (dbcollection.java:100)
At FileUpload.UploadFileTest.test (uploadfiletest.java:35)
At FileUpload.UploadFileTest.main (uploadfiletest.java:41)
December 22, 2014 5:28:08 pm Com.mongodb.DBTCPConnector initdirectconnection
Warning: Exception executing ismaster command on/192.168.1.249:10003
Java.io.IOException:couldn ' t connect to [/192.168.1.249:10003] Bc:java.net.SocketTimeoutException:connect timed out
At Com.mongodb.dbport._open (dbport.java:214)
At Com.mongodb.DBPort.go (dbport.java:107)
At Com.mongodb.DBPort.go (dbport.java:88)
At Com.mongodb.DBPort.findOne (dbport.java:143)
At Com.mongodb.DBPort.runCommand (dbport.java:148)
At Com.mongodb.DBTCPConnector.initDirectConnection (dbtcpconnector.java:539)
At Com.mongodb.DBTCPConnector.checkMaster (dbtcpconnector.java:518)
At Com.mongodb.DBTCPConnector.say (dbtcpconnector.java:174)
At Com.mongodb.DBTCPConnector.say (dbtcpconnector.java:155)
At Com.mongodb.dbapilayer$mycollection.insert (dbapilayer.java:249)
At Com.mongodb.dbapilayer$mycollection.insert (dbapilayer.java:205)
At Com.mongodb.DBCollection.insert (dbcollection.java:57)
At Com.mongodb.DBCollection.insert (dbcollection.java:100)
At FileUpload.UploadFileTest.test (uploadfiletest.java:35)
At FileUpload.UploadFileTest.main (uploadfiletest.java:41)
Some of the usual workarounds. For example, the connection timeout due to network reasons can be solved. It's pretty specific.
http://lingqi1818.iteye.com/blog/1317433
But assuming that these things are not linked, it means that some ports on the server are not open and cannot be connected.
Workaround to first configure the IP table to open some ports, and then restart server.
Root enters server
Vi/etc/sysconfig/iptables
Join
-A input-m state--state new-m tcp-p TCP--dport 10002-j ACCEPT (the port opened here is 10002)
Save exit
Service Iptables Restart
Try the code again, get it done!
MongoDB on Java link Server appears with connect time out problem