move connection outside devices loop, activated retry