MongoDB C++ auto reconnect

92 views
Skip to first unread message

Carl Z.

unread,
Mar 21, 2013, 3:09:24 PM3/21/13
to mongod...@googlegroups.com
Hello!

I've been facing a problem with auto reconnect. I've set it to true but whenever I restart MongoDB my c++ app crashes with error:
Thu Mar 21 12:02:55.245 DBClientCursor::init call() failed
exception: DBClientBase::findN: transport error: 127.0.0.1:27017 ns: ..... query .......

I could just try-catch all query but that would be kinda insane, so... is there an easier solution for this? 

Asya Kamsky

unread,
Mar 22, 2013, 12:09:27 AM3/22/13
to mongod...@googlegroups.com
If you look at the code you will see that there are situations where an exception is thrown even when autoReconnect is set.
Can you check the server logs and see what is actually going on that is causing the connections to fail?

Asya

Carl Z.

unread,
Mar 22, 2013, 9:25:13 AM3/22/13
to mongod...@googlegroups.com
Sadly there is nothing in the logs.

Carl Z.

unread,
Mar 22, 2013, 10:03:21 AM3/22/13
to mongod...@googlegroups.com
Also if I catch the exception at the first query on the next one it reconnects to mongo. That doesn't really help though since I don't know when will mongo crash (or a simple restart, anything), so I still have to catch exception at every query.
Reply all
Reply to author
Forward
0 new messages