Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Message Event handler missing messages randomly #4361

Closed
sushilronghe99 opened this issue Apr 26, 2024 · 1 comment
Closed

New Message Event handler missing messages randomly #4361

sushilronghe99 opened this issue Apr 26, 2024 · 1 comment

Comments

@sushilronghe99
Copy link

Code that causes the issue

client.add_event_handler(new_message_hdl)
async def processMessage(client,message):
            await asyncio.sleep(0.03) 
            me = await client.get_me()
            #do some stuff with this message

@events.register(events.NewMessage(incoming=True))
async def new_message_hdl(event):
        asyncio.create_task(processMessage(event.client,event.message))```

### Expected behavior

All new messages should be received from telegram. 

### Actual behavior

I have joined around 10 channels and  expecting that when ever there is new message in the channel it should be received in my processMessage routine. Tested this for over a month now. Some days it works perfectly fine not missing a single message and some days it misses few messages. 

I have not changed my code for over a month since the tested has started. 


### Traceback

_No response_

### Telethon version

1.34.0

### Python version

3.10.4

### Operating system (including distribution name and version)

Ubuntu,Mac 

### Other details

In past (during early days of development of this app) I was using the following code and it was receiving all messages. As far as i remember. 
```@client.on(events.NewMessages(chats = [names of the channels]))```
Later i have changed the implementation to the register, since the channel names are dynamic, i had to use this approach. 
```@events.register(events.NewMessage(incoming=True))```

I have observed that the message which comes after a long pause in the channel (lets say first message of the day) or a when there is sudden surge of messages in all channels the message are missed. Its kind of a blackout for 1-2 minute. After that everything goes normal. I am not sure if this black out is happening from telegram side or its a telethon problem. 

I have also implemented a periodic (60 sec) getMe method for all clients just to ensure that telegram knows the clients are willing to accepts notifications. Every minute the logs are printing and during the blackouts also the getMe methods are working fine. 

Please let me know if i should provide more details. Any help here would be appreciated. 




### Checklist

- [X] The error is in the library's code, and not in my own.
- [X] I have searched for this issue before posting it and there isn't an open duplicate.
- [X] I ran `pip install -U https://github.com/LonamiWebs/Telethon/archive/v1.zip` and triggered the bug in the latest version.
@Lonami
Copy link
Member

Lonami commented Apr 27, 2024

#4345.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants