- count = 0
- while count < timeout:
- try:
- connection.connect((adress, port))
- LOGGER.debug('%s:%s is reachable!', adress, port)
- return True
- except socket.error:
- count += 1
- time.sleep(1)
- continue
- LOGGER.error('%s:%s is not reachable.', adress, port)
+ connection.settimeout(10)
+ hostname = urllib.parse.urlparse(endpoint).hostname
+ port = urllib.parse.urlparse(endpoint).port
+ if not port:
+ port = 443 if urllib.parse.urlparse(endpoint).scheme == "https" else 80
+ try:
+ connection.connect((hostname, port))
+ LOGGER.debug('%s:%s is reachable!', hostname, port)
+ return True
+ except socket.error:
+ LOGGER.exception('%s:%s is not reachable.', hostname, port)