Telethon: timeout and authKeyUnregisteredError

Hi, sometimes, during big downloads I get this exception:

  File "/usr/local/lib/python3.5/dist-packages/telethon/extensions/tcp_client.py", line 94, in read
    partial = self._socket.recv(bytes_left)
BlockingIOError: [Errno 11] Resource temporarily unavailable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/elenoon/telegram-chanel-copier/channel_copier.py", line 112, in main
    client.download_msg_media(msg.media, 'media/{}_{}'.format(entity.id, msg.id))
  File "/usr/local/lib/python3.5/dist-packages/telethon/telegram_client.py", line 594, in download_msg_media
    add_extension, progress_callback)
  File "/usr/local/lib/python3.5/dist-packages/telethon/telegram_client.py", line 672, in download_document
    progress_callback=progress_callback
  File "/usr/local/lib/python3.5/dist-packages/telethon/telegram_client.py", line 724, in download_file
    progress_callback=progress_callback
  File "/usr/local/lib/python3.5/dist-packages/telethon/telegram_bare_client.py", line 313, in download_file
    GetFileRequest(input_location, offset, part_size))
  File "/usr/local/lib/python3.5/dist-packages/telethon/telegram_client.py", line 247, in invoke
    request, timeout=timeout, updates=updates)
  File "/usr/local/lib/python3.5/dist-packages/telethon/telegram_bare_client.py", line 189, in invoke
    self.sender.receive(request, timeout, updates=updates)
  File "/usr/local/lib/python3.5/dist-packages/telethon/network/mtproto_sender.py", line 100, in receive
    seq, body = self._transport.receive(timeout)
  File "/usr/local/lib/python3.5/dist-packages/telethon/network/tcp_transport.py", line 45, in receive
    packet_length_bytes = self.tcp_client.read(4, timeout)
  File "/usr/local/lib/python3.5/dist-packages/telethon/extensions/tcp_client.py", line 111, in read
    'The read operation exceeded the timeout.') from error
TimeoutError: The read operation exceeded the timeout.

And after that, if I try to invoke anything it will give me “you must be connected” error, and if I try to disconnect and connect it needs to re sign in.

any idea?

thanks

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (11 by maintainers)

Most upvoted comments

CONNECTION_APP_VERSION_EMPTY

See https://github.com/LonamiWebs/Telethon/commit/2af962230f3642f2821dba9a8b0b2805246d7ac9. Guess I better push that new version to pip.

Edit: Done. Please upgrade and try again.

but why the download speed with big files is so slow?

No idea, official clients may use a separate connection, or several to get different parts at the same time, or maybe request larger chunk sizes…