fixing idling issues & added connection retry logic