diff --git a/core/services/helper/main.py b/core/services/helper/main.py index 7cfb99fba1..9b4166a917 100755 --- a/core/services/helper/main.py +++ b/core/services/helper/main.py @@ -305,14 +305,18 @@ def simple_http_request( @staticmethod @temporary_cache(timeout_seconds=1) # a temporary cache helps us deal with changes in metadata - def detect_service(port: int) -> ServiceInfo: + def detect_service(port: int, retries=3) -> ServiceInfo: path = port_to_service_map.get(port) info = ServiceInfo(valid=False, title="Unknown", documentation_url="", versions=[], port=port, path=path) - response = Helper.simple_http_request( - "127.0.0.1", port=port, path="/", timeout=1.0, method="GET", follow_redirects=10 - ) log_msg = f"Detecting service at port {port}" + for _ in range(retries): + response = Helper.simple_http_request( + "127.0.0.1", port=port, path="/", timeout=2.0, method="GET", follow_redirects=10 + ) + if response.status is not None: + break + if response.status != http.client.OK: # If not valid web server, documentation will not be available logger.debug(f"{log_msg}: Invalid: {response.status} - {response.decoded_data}")