Optimize the connection retry logic and time out interval.