From 9ef4dd6d3572336355709cd4bf31cc06aa5df485 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Wed, 13 Jan 2021 01:58:02 +0100 Subject: [PATCH] fix: handle OSError exception on asyncio sockets --- yunodiagnoser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yunodiagnoser.py b/yunodiagnoser.py index e5f6816..49abffe 100644 --- a/yunodiagnoser.py +++ b/yunodiagnoser.py @@ -295,7 +295,7 @@ async def check_port_is_open(ip, port): try: _, writer = await asyncio.wait_for(futur, timeout=2) - except (asyncio.TimeoutError, ConnectionRefusedError): + except (asyncio.TimeoutError, ConnectionRefusedError, OSError): # OSError: [Errno 113] No route to host return False except Exception: import traceback @@ -350,7 +350,7 @@ async def check_smtp(request): try: reader, writer = await asyncio.wait_for(futur, timeout=2) - except (asyncio.TimeoutError, ConnectionRefusedError): + except (asyncio.TimeoutError, ConnectionRefusedError, OSError): # OSError: [Errno 113] No route to host return json_response({ 'status': "error_smtp_unreachable", 'content': "Could not open a connection on port 25, probably because of a firewall or port forwarding issue"