handle more client connection errors
This commit is contained in:
parent
af7fcc66fd
commit
0940921383
|
@ -2,7 +2,8 @@ import logging
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from aiohttp import ClientSession, ClientTimeout, TCPConnector
|
from aiohttp import ClientSession, ClientTimeout, TCPConnector
|
||||||
from aiohttp.client_exceptions import ClientConnectorError, ServerTimeoutError
|
from aiohttp.client_exceptions import ClientConnectionError, ClientSSLError
|
||||||
|
from asyncio.exceptions import TimeoutError as AsyncTimeoutError
|
||||||
from aputils import Nodeinfo, WellKnownNodeinfo
|
from aputils import Nodeinfo, WellKnownNodeinfo
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from cachetools import LRUCache
|
from cachetools import LRUCache
|
||||||
|
@ -124,12 +125,14 @@ class HttpClient:
|
||||||
except JSONDecodeError:
|
except JSONDecodeError:
|
||||||
logging.verbose(f'Failed to parse JSON')
|
logging.verbose(f'Failed to parse JSON')
|
||||||
|
|
||||||
except (ClientConnectorError, ServerTimeoutError):
|
except ClientSSLError:
|
||||||
|
logging.verbose(f'SSL error when connecting to {urlparse(url).netloc}')
|
||||||
|
|
||||||
|
except (AsyncTimeoutError, ClientConnectionError):
|
||||||
logging.verbose(f'Failed to connect to {urlparse(url).netloc}')
|
logging.verbose(f'Failed to connect to {urlparse(url).netloc}')
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
raise e
|
|
||||||
|
|
||||||
|
|
||||||
async def post(self, url, message):
|
async def post(self, url, message):
|
||||||
|
@ -158,8 +161,11 @@ class HttpClient:
|
||||||
logging.verbose(f'Received error when pushing to {url}: {resp.status}')
|
logging.verbose(f'Received error when pushing to {url}: {resp.status}')
|
||||||
return logging.verbose(await resp.read()) # change this to debug
|
return logging.verbose(await resp.read()) # change this to debug
|
||||||
|
|
||||||
except (ClientConnectorError, ServerTimeoutError):
|
except ClientSSLError:
|
||||||
logging.verbose(f'Failed to connect to {url}')
|
logging.warning(f'SSL error when pushing to {urlparse(url).netloc}')
|
||||||
|
|
||||||
|
except (AsyncTimeoutError, ClientConnectionError):
|
||||||
|
logging.warning(f'Failed to connect to {urlparse(url).netloc} for message push')
|
||||||
|
|
||||||
## prevent workers from being brought down
|
## prevent workers from being brought down
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
Loading…
Reference in a new issue