TelegramPlayGround / pyrogram

PyroGramFORK | Telegram MTProto API framework in Python for users and bots | PyroGramFORK
https://telegramplayground.github.io/pyrogram/
GNU Lesser General Public License v3.0
63 stars 12 forks source link

Repeated Connection Lost/Bot doesn't start #17

Closed hudvaska closed 1 week ago

hudvaska commented 3 months ago

Checklist

Description

My project was working fine until about a week ago where it just stopped working out of nowhere. I wasn't on the latest version at the time so I updated and I am still getting the same result. I had no issues before and have never gotten a log like this before. Been trying to connect about 3-4 days and changing my IP doesn't help. My current pyrogram version is 2.1.25-TL-178. Please let me know if there is anything I can do to help.

Steps to reproduce

  1. install pyrogram using pip install pyrotgfork
  2. run sample code
  3. get connection lost error :(

Code example

import asyncio
from pyrogram import Client

api_id = 0  # usually real values from https://my.telegram.org/apps
api_hash = ""

async def main():
    async with Client("my_account", api_id, api_hash, test_mode=True) as app:
        await app.send_message(chat_id="me", text="Greetings from **Pyrogram**!")

asyncio.run(main())

Logs

Traceback (most recent call last):
  File "/home/user/.local/lib/python3.11/site-packages/pyrogram/connection/transport/tcp/tcp.py", line 101, in send
    await self.writer.drain()
  File "/usr/lib/python3.11/asyncio/streams.py", line 392, in drain
    await self._protocol._drain_helper()
  File "/usr/lib/python3.11/asyncio/streams.py", line 166, in _drain_helper
    raise ConnectionResetError('Connection lost')
ConnectionResetError: Connection lost
Send exception: ConnectionResetError Connection lost
annihilatorrrr commented 3 months ago

true, these is the real issue with this pyro

hudvaska commented 3 months ago

true, these is the real issue with this pyro

just sucks that this happened out of nowhere. worked excellent for about a month straight and now the bot won't connect at all.

hudvaska commented 3 months ago

Version 2.1.25 fixed problem.

SpEcHiDe commented 3 months ago

I believe it was a coincidence that updating the version fixed the issue, since there weren't any reports of Telegram downtimes in the past two days. But, I believe, ideally, the library should be able to recover from the ConnectionLost issues without having to restart the program.

You may unsubscribe from notifications if you are not interested on receiving notifications from here.

hudvaska commented 3 months ago

I believe the bot would have recovered if it was possible to. I'm still not sure what the causes of the connection lost were but I dont think it was network issues as weird as that may sound. I also forgot to say this in the issue (I thought I included it, sorry) but that message was repeating every 30 seconds to minute. Seemed like it was continiously trying to connect/reconnect.

SpEcHiDe commented 1 month ago

Please retry with pyrotgfork==2.1.32.9 and reply here if issue still persists.

Jigarvarma2005 commented 2 weeks ago

I tried with latest version pyrotgfork==2.1.32.12 still error

[08/07/2024 08:59:10][asyncio][WARNING] ==> socket.send() raised exception.  
[08/07/2024 08:59:10][pyrogram.connection.transport.tcp.tcp][ERROR] ==> Send exception: ConnectionResetError Connection lost
Traceback (most recent call last):                                                                                                               
  File "/usr/local/lib/python3.11/dist-packages/pyrogram/connection/transport/tcp/tcp.py", line 146, in send
    await self.writer.drain()                                                                                                                    
  File "/usr/lib/python3.11/asyncio/streams.py", line 392, in drain                                                                              
    await self._protocol._drain_helper()                                                                                                         
  File "/usr/lib/python3.11/asyncio/streams.py", line 166, in _drain_helper    
    raise ConnectionResetError('Connection lost')                                                                                                
ConnectionResetError: Connection lost 
SpEcHiDe commented 1 week ago

Please try again with

pip uninstall -y pyrogram && pip install https://github.com/TelegramPlayGround/pyrogram/archive/unfixe-error-d.zip
Jigarvarma2005 commented 1 week ago

okay i have installed this version, if error occurs i will share logs here!!

Jigarvarma2005 commented 1 week ago

You closed it before my confirmation, anyway it's fixed 👍