MongoDB on Java link Server appears with connect time out problem

Source: Internet
Author: User
Tags findone

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.