Retry connection to mongodb