Hi.
Sometimes when i connect to telegram, immediately it gets the below log:
telethon.network.connection.connection: The server closed the connection
and disconnects from telegram. it happens much and not just a few times. after that async.io runs into exception until i restart the service. below is the full log:
[ INFO/2020-01-03 06:34:34,840] telethon.network.mtprotosender: Connecting to 149.154.167.91:443/TcpFull...
[ INFO/2020-01-03 06:34:34,846] telethon.network.mtprotosender: Connection to 149.154.167.91:443/TcpFull complete!
[ INFO/2020-01-03 06:34:34,860] telethon.network.connection.connection: The server closed the connection
[ERROR/2020-01-03 06:34:34,868] asyncio: Exception in callback Task._wakeup(<Task finishe...> result=None>)
handle: <Handle Task._wakeup(<Task finishe...> result=None>)>
Traceback (most recent call last):File "/usr/lib/python3.5/asyncio/events.py", line 125, in _run
self._callback(*self._args)
File "/usr/lib/python3.5/asyncio/tasks.py", line 307, in _wakeup
self._step()
File "/usr/lib/python3.5/asyncio/tasks.py", line 265, in _step
if self._fut_waiter.cancel():
File "/usr/lib/python3.5/asyncio/tasks.py", line 214, in cancel
if self._fut_waiter.cancel():
.
.
.
File "/usr/lib/python3.5/asyncio/tasks.py", line 214, in cancel
if self._fut_waiter.cancel():
File "/usr/lib/python3.5/asyncio/tasks.py", line 211, in cancel
if self.done():
File "/usr/lib/python3.5/asyncio/futures.py", line 256, in done
return self._state != _PENDING
RecursionError: maximum recursion depth exceeded in comparison
so what should i do to reconnect again while this happen or exit from the service to restart it automaticly?
You should upgrade your Python installation, since Python 3.5 has this kind of issue.
You should upgrade your Python installation, since Python 3.5 has this kind of issue.
Just curious, what version of python you recommend? I have the similar issue with telethon 1.13 + python3.6, bot disconnect/crashes itself after some time and I need to force restart my bot.
Any version above 3.5 is fine. Network errors are unavoidable and the library may fail to autoreconnect which is expected. This particular error is a Python 3.5 specific issue. If you believe you see a bug on newer versions, open a new issue.
Most helpful comment
You should upgrade your Python installation, since Python 3.5 has this kind of issue.