Forums

connectionrefusederror from an upgraded account - telethon

https://www.pythonanywhere.com/forums/topic/31927/

I looked at link above and upgraded account to get messages from telegram as free account has limited internet access. But this error stops the process. This was tried from bash console. From actual page error I get is

ERROR from actual page

EOFError at /app/show_messages_from_telegram_channel/
EOF when reading a line

FROM BASH CONSOLE

code:

>>> from telethon import TelegramClient
>>> from telethon.tl.types import MessageMediaWebPage, WebPageEmpty
>>> display_url_link = []

>>> client = TelegramClient(session_name, api_id, api_hash)
>>> client
<telethon.client.telegramclient.TelegramClient object at 0x7fe6e69b6f10>
>>> client.start()

error:

Attempt 1 at connecting failed: ConnectionRefusedError: [Errno 111] Connect call failed ('149.154.167.51', 443)
Attempt 2 at connecting failed: ConnectionRefusedError: [Errno 111] Connect call failed ('149.154.167.51', 443)
Attempt 3 at connecting failed: ConnectionRefusedError: [Errno 111] Connect call failed ('149.154.167.51', 443)
Attempt 4 at connecting failed: ConnectionRefusedError: [Errno 111] Connect call failed ('149.154.167.51', 443)
Attempt 5 at connecting failed: ConnectionRefusedError: [Errno 111] Connect call failed ('149.154.167.51', 443)
Attempt 6 at connecting failed: ConnectionRefusedError: [Errno 111] Connect call failed ('149.154.167.51', 443)



Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/nightly/.virtualenvs/.my3.8virtualenv/lib/python3.8/site-packages/telethon/client/auth.py", line 128, in start
    else self.loop.run_until_complete(coro)
  File "/usr/lib/python3.8/asyncio/base_events.py", line 608, in run_until_complete
    return future.result()
  File "/home/nightly/.virtualenvs/.my3.8virtualenv/lib/python3.8/site-packages/telethon/client/auth.py", line 135, in _start
    await self.connect()
  File "/home/nightly/.virtualenvs/.my3.8virtualenv/lib/python3.8/site-packages/telethon/client/telegrambaseclient.py", line 544, in connect
    if not await self._sender.connect(self._connection(
  File "/home/nightly/.virtualenvs/.my3.8virtualenv/lib/python3.8/site-packages/telethon/network/mtprotosender.py", line 134, in connect
    await self._connect()
  File "/home/nightly/.virtualenvs/.my3.8virtualenv/lib/python3.8/site-packages/telethon/network/mtprotosender.py", line 260, in _connect
    raise ConnectionError('Connection to Telegram failed {} time(s)'.format(self._retries))
ConnectionError: Connection to Telegram failed 5 time(s)

Did you start a new console after upgrade?

Tried with new console. It worked. Thank you fjl.

Glad to hear that!