Hello,
I am use mongo db 2.0.2 on 64 bit RHEL. Due to nfs file system, data directory is has been corrupted.
Mongo server process is running smoothely.
When I try to connect using mongo client, it hangs out for around 8-9 minutes . No matter whether I pass correct or incorrect password -
./mongo localhost:27017/admin -uadmin -p
MongoDB shell version: 2.0.2
Enter password:
connecting to: localhost:27017/admin
After hang out is over, it throws following exception -
connecting to: localhost:27017/admin
Mon Sep 10 23:16:58 Socket recv() errno:104 Connection reset by peer
127.0.0.1:27017Mon Sep 10 23:16:58 SocketException: remote:
127.0.0.1:27017 error: 9001 socket exception [1] server [
127.0.0.1:27017]
Mon Sep 10 23:16:58 DBClientCursor::init call() failed
Mon Sep 10 23:16:58 Error: Error during mongo startup. :: caused by :: DBClientBase::findN: transport error: localhost:27017 query: { whatsmyuri: 1 } shell/mongo.js:86
exception: connect failed
Can I prevent this hang out ? How can I set connection time out and socket time out ?
Thanks in advance. Let me know if you need more info.
Switching to coding part -
I want exception to be thrown after 10 seconds, if the connection is not establised -
MongoOptions options = new MongoOptions()
options.connectTimeout=10000
options.socketTimeout=10000 options.connectionsPerHost = 50
mongo = new Mongo(getReplicaSetServerAddresses(), options)
after this code I do authenticate the mongo db.
But the exception is not being thrown after 10 seconds.Regards,
Prashant Gupta