On Mon, Jul 29, 2013 at 8:19 AM, Fatih Arslan <
ftha...@gmail.com> wrote:
> The problem I have is, when the connection to the mongodb server fails (the
> server drops the connection sometimes or mongodb server fails), then my
> pointer to the session variable doesn't work anymore. Even if the internet
> connection comes back, mgo driver doesn't reconnect anymore, instead of this
> I get the error (when I do Find().One() method call):
It actually reconnects. What it doesn't do is to reset the session
you're holding, because that might hide real issues in your
application.
There are two easy ways to get rid of the error:
1) Call Refresh on the session, which makes it discard (or put back in
the pool, if the connection is good) the connection it's holding, and
pick a new one when necessary.
2) Instead of using a single session, use many by calling session.Copy
when you need a new session, and then call session.Close when you're
done with it. This will also mean you're using multiple connections to
the database, when necessary.
Please let us know if you need further details.
gustavo @
http://niemeyer.net