mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-10 19:46:36 +03:00
Trigger automatic reconnection if server kicks us (#94)
This commit is contained in:
parent
6e1798d6ac
commit
fb4885aed0
|
@ -214,6 +214,13 @@ class TelegramClient:
|
|||
self._reconnect_to_dc(error.new_dc)
|
||||
return self.invoke(request, timeout=timeout, throw_invalid_dc=True)
|
||||
|
||||
except ConnectionResetError:
|
||||
self._logger.info('Server disconnected us. Reconnecting and '
|
||||
'resending request...')
|
||||
self.reconnect()
|
||||
self.invoke(request, timeout=timeout,
|
||||
throw_invalid_dc=throw_invalid_dc)
|
||||
|
||||
except FloodWaitError:
|
||||
self.disconnect()
|
||||
raise
|
||||
|
@ -842,9 +849,12 @@ class TelegramClient:
|
|||
for handler in self.update_handlers:
|
||||
handler(result)
|
||||
|
||||
except ConnectionResetError:
|
||||
self._logger.info('Server disconnected us. Reconnecting...')
|
||||
self.reconnect()
|
||||
|
||||
except TimeoutError:
|
||||
self._logger.debug('Receiving updates timed out')
|
||||
self.reconnect()
|
||||
|
||||
except ReadCancelledError:
|
||||
self._logger.info('Receiving updates cancelled')
|
||||
|
|
Loading…
Reference in New Issue
Block a user