Connect time out occurs in mongodb on the java linked server. mongodbconnect

Source: Internet
Author: User
Tags findone

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!

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.