Closed iamsaso closed 7 years ago
@sasso this seems like it might be a little heavy to be making calls every n seconds, perhaps we can find a lighter touch way. I wonder if a better way is handling errored calls that receive an EOF and retry them by refreshing the session then. I found this discussion https://github.com/go-mgo/mgo/issues/49 and https://groups.google.com/forum/#!topic/mgo-users/XM0rc6p-V-8 regarding this topic.
I was looking into that issues and global EOF handler would be cool, I also checked my logs and i never got the EOF but connection reset
so i guess there are other failures that session.ping
does catch. I know this is a bit heavy but just wanted too put it here to start a discussion and find a better solution... but for now this works and helps me keep my app live when this issue occurs.
I had to implement and easy way to reconnect the session if mongodb server was restarted or connection was dropped for any other reason. Would love to hear any suggestions if there is a better way to handle this.