Try to reconnect for given  attempts.