mirror of
https://github.com/matrix-org/pantalaimon.git
synced 2025-03-12 01:06:41 -04:00
pantalaimon: Catch all aiohttp client connection errors.
This commit is contained in:
parent
f1fefb952c
commit
e84bcea389
@ -2,8 +2,7 @@ import asyncio
|
|||||||
from pprint import pformat
|
from pprint import pformat
|
||||||
from typing import Any, Dict, Optional
|
from typing import Any, Dict, Optional
|
||||||
|
|
||||||
from aiohttp.client_exceptions import (ClientProxyConnectionError,
|
from aiohttp.client_exceptions import ClientConnectionError
|
||||||
ServerDisconnectedError)
|
|
||||||
from nio import (AsyncClient, ClientConfig, EncryptionError,
|
from nio import (AsyncClient, ClientConfig, EncryptionError,
|
||||||
GroupEncryptionError, KeysQueryResponse, MegolmEvent,
|
GroupEncryptionError, KeysQueryResponse, MegolmEvent,
|
||||||
RoomEncryptedEvent, SyncResponse,
|
RoomEncryptedEvent, SyncResponse,
|
||||||
@ -212,8 +211,7 @@ class PanClient(AsyncClient):
|
|||||||
break
|
break
|
||||||
|
|
||||||
except (
|
except (
|
||||||
ClientProxyConnectionError,
|
ClientConnectionError,
|
||||||
ServerDisconnectedError,
|
|
||||||
ConnectionRefusedError
|
ConnectionRefusedError
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
@ -18,8 +18,7 @@ import keyring
|
|||||||
import logbook
|
import logbook
|
||||||
from aiohttp import ClientSession, web
|
from aiohttp import ClientSession, web
|
||||||
from aiohttp.client_exceptions import (ContentTypeError,
|
from aiohttp.client_exceptions import (ContentTypeError,
|
||||||
ClientProxyConnectionError,
|
ClientConnectionError)
|
||||||
ServerDisconnectedError)
|
|
||||||
from appdirs import user_data_dir
|
from appdirs import user_data_dir
|
||||||
from logbook import StderrHandler
|
from logbook import StderrHandler
|
||||||
from multidict import CIMultiDict
|
from multidict import CIMultiDict
|
||||||
@ -322,9 +321,7 @@ class ProxyDaemon:
|
|||||||
status=response.status,
|
status=response.status,
|
||||||
text=await response.text()
|
text=await response.text()
|
||||||
)
|
)
|
||||||
except (ClientProxyConnectionError,
|
except ClientConnectionError as e:
|
||||||
ServerDisconnectedError,
|
|
||||||
ConnectionRefusedError) as e:
|
|
||||||
return web.Response(status=500, text=str(e))
|
return web.Response(status=500, text=str(e))
|
||||||
|
|
||||||
async def router(self, request):
|
async def router(self, request):
|
||||||
@ -409,9 +406,7 @@ class ProxyDaemon:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
response = await self.forward_request(request)
|
response = await self.forward_request(request)
|
||||||
except (ClientProxyConnectionError,
|
except ClientConnectionError as e:
|
||||||
ServerDisconnectedError,
|
|
||||||
ConnectionRefusedError) as e:
|
|
||||||
return web.Response(status=500, text=str(e))
|
return web.Response(status=500, text=str(e))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -522,9 +517,7 @@ class ProxyDaemon:
|
|||||||
params=query,
|
params=query,
|
||||||
token=client.access_token
|
token=client.access_token
|
||||||
)
|
)
|
||||||
except (ClientProxyConnectionError,
|
except ClientConnectionError as e:
|
||||||
ServerDisconnectedError,
|
|
||||||
ConnectionRefusedError) as e:
|
|
||||||
return web.Response(status=500, text=str(e))
|
return web.Response(status=500, text=str(e))
|
||||||
|
|
||||||
if response.status == 200:
|
if response.status == 200:
|
||||||
@ -556,9 +549,7 @@ class ProxyDaemon:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
response = await self.forward_request(request)
|
response = await self.forward_request(request)
|
||||||
except (ClientProxyConnectionError,
|
except ClientConnectionError as e:
|
||||||
ServerDisconnectedError,
|
|
||||||
ConnectionRefusedError) as e:
|
|
||||||
return web.Response(status=500, text=str(e))
|
return web.Response(status=500, text=str(e))
|
||||||
|
|
||||||
if response.status == 200:
|
if response.status == 200:
|
||||||
@ -613,9 +604,7 @@ class ProxyDaemon:
|
|||||||
except GroupEncryptionError:
|
except GroupEncryptionError:
|
||||||
await client.share_group_session(room_id)
|
await client.share_group_session(room_id)
|
||||||
response = await client.room_send(room_id, msgtype, content, txnid)
|
response = await client.room_send(room_id, msgtype, content, txnid)
|
||||||
except (ClientProxyConnectionError,
|
except ClientConnectionError as e:
|
||||||
ServerDisconnectedError,
|
|
||||||
ConnectionRefusedError) as e:
|
|
||||||
return web.Response(status=500, text=str(e))
|
return web.Response(status=500, text=str(e))
|
||||||
|
|
||||||
return web.Response(
|
return web.Response(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user