Handle errors at connection level

Closes #4042.
This commit is contained in:
Lonami Exo 2023-03-12 17:43:36 +01:00
parent acd3407418
commit be59c36ed3

View File

@ -507,6 +507,18 @@ class MTProtoSender:
self._log.info('Connection closed while receiving data') self._log.info('Connection closed while receiving data')
self._start_reconnect(e) self._start_reconnect(e)
return return
except InvalidBufferError as e:
if e.code == 429:
self._log.warning('Server indicated flood error at transport level: %s', e)
await self._disconnect(error=e)
else:
self._log.exception('Server sent invalid buffer')
self._start_reconnect(e)
return
except Exception as e:
self._log.exception('Unhandled error while receiving data')
self._start_reconnect(e)
return
try: try:
message = self._state.decrypt_message_data(body) message = self._state.decrypt_message_data(body)
@ -532,7 +544,7 @@ class MTProtoSender:
self._start_reconnect(e) self._start_reconnect(e)
return return
except Exception as e: except Exception as e:
self._log.exception('Unhandled error while receiving data') self._log.exception('Unhandled error while decrypting data')
self._start_reconnect(e) self._start_reconnect(e)
return return