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 general solutions, such as connection timeouts due to network reasons, can be resolved as such. It's pretty detailed.
http://lingqi1818.iteye.com/blog/1317433
However, if these items are not linked, it means that some of the ports on the server are not open causing the connection to be non-connected.
Workaround first Configure the IP table to open some ports, and then restart server.
Root enters server
Vi/etc/sysconfig/iptables
Add to
-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 a Java linked server appears with connect time out problem