mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-25 19:03:46 +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)
|
self._reconnect_to_dc(error.new_dc)
|
||||||
return self.invoke(request, timeout=timeout, throw_invalid_dc=True)
|
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:
|
except FloodWaitError:
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
raise
|
raise
|
||||||
|
@ -842,9 +849,12 @@ class TelegramClient:
|
||||||
for handler in self.update_handlers:
|
for handler in self.update_handlers:
|
||||||
handler(result)
|
handler(result)
|
||||||
|
|
||||||
|
except ConnectionResetError:
|
||||||
|
self._logger.info('Server disconnected us. Reconnecting...')
|
||||||
|
self.reconnect()
|
||||||
|
|
||||||
except TimeoutError:
|
except TimeoutError:
|
||||||
self._logger.debug('Receiving updates timed out')
|
self._logger.debug('Receiving updates timed out')
|
||||||
self.reconnect()
|
|
||||||
|
|
||||||
except ReadCancelledError:
|
except ReadCancelledError:
|
||||||
self._logger.info('Receiving updates cancelled')
|
self._logger.info('Receiving updates cancelled')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user