From: Arran Cudbard-Bell Date: Wed, 24 May 2023 01:48:32 +0000 (-0400) Subject: radhttpcheck: Catch broken pipe error X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb039ba6c8bb4360ef11bf874aa5a6effd46fd99;p=thirdparty%2Ffreeradius-server.git radhttpcheck: Catch broken pipe error --- diff --git a/scripts/health/radhttpcheck/radhttpcheck.py b/scripts/health/radhttpcheck/radhttpcheck.py index 5fe76f69fca..952d108df27 100755 --- a/scripts/health/radhttpcheck/radhttpcheck.py +++ b/scripts/health/radhttpcheck/radhttpcheck.py @@ -40,7 +40,10 @@ class RadiusHealthCheckHandler(BaseHTTPRequestHandler): self.send_header("Content-Type", "application/json") self.send_header("Content-Length", str(len(content))) self.end_headers() - self.wfile.write(bytes(content, 'utf8')) + try: + self.wfile.write(bytes(content, 'utf8')) + except BrokenPipeError: + pass def codeToStr(self, code): code_map = { @@ -109,6 +112,7 @@ class RadiusHealthCheckHandler(BaseHTTPRequestHandler): req.add_message_authenticator() # We now block until retries and timeout have expired + rsp = None try: rsp = client.SendPacket(req) except pyrad.packet.PacketError as e: @@ -119,6 +123,7 @@ class RadiusHealthCheckHandler(BaseHTTPRequestHandler): self.genericResponse(500, json.dumps({"msg": "Internal error: " + str(e) })) # Internal error finally: del client # Ensure the socket is closed in a timely fashion + if not rsp: return # Deal with response code mismatches diff --git a/scripts/health/radhttpcheck/radhttpcheck.yml b/scripts/health/radhttpcheck/radhttpcheck.yml index 12d06114dd1..e1211cee1c6 100644 --- a/scripts/health/radhttpcheck/radhttpcheck.yml +++ b/scripts/health/radhttpcheck/radhttpcheck.yml @@ -3,7 +3,7 @@ listen: address: '*' port: 8080 # URLs the healthcheck script will respond on, and the various types of requests they create -endpoints: +healthchecks: '/acct': port: 1813 secret: testing123