Connect time out occurs in mongodb on the java linked server. mongodbconnect
Exception Information
December 22 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 (dbtcpconne. 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. apsaradb for mongodb. DBCollection. insert (DBCollection. java: 100)
At fileUpload. UploadFileTest. test (UploadFileTest. java: 35)
At fileUpload. UploadFileTest. main (UploadFileTest. java: 41)
December 22 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 (dbtcpconne. java: 539)
At com. mongodb. DBTCPConnector. checkMaster (dbtcpconne. java: 518)
At com. mongodb. DBTCPConnector. say (dbtcpconne. java: 174)
At com. mongodb. DBTCPConnector. say (dbtcpconne. 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. apsaradb for mongodb. DBCollection. insert (DBCollection. java: 100)
At fileUpload. UploadFileTest. test (UploadFileTest. java: 35)
At fileUpload. UploadFileTest. main (UploadFileTest. java: 41)
Some common solutions, such as network connection timeout, can be solved in this way. The lecture is quite detailed.
Http://lingqi1818.iteye.com/blog/1317433
However, if these items are not linked, some ports on the server are not opened, causing non-connection.
To solve this problem, first configure the ip table to open some ports and then restart the server.
Enter the server as root
Vi/etc/sysconfig/iptables
Add
-A input-m state -- state NEW-m tcp-p tcp -- dport 10002-j ACCEPT (the port opened here is 10002)
Save and exit
Service iptables restart
Try the code again!