client.on(events.NewMessage()) not triggered on Docker
francestu96 opened this issue · comments
Code that causes the issue
import os
from dotenv import load_dotenv
from telethon.sessions import StringSession
from telethon.sync import TelegramClient, events
load_dotenv()
with TelegramClient(StringSession(os.getenv('TELEGRAM_SESSION')), int(os.getenv('TELEGRAM_API_ID')), os.getenv('TELEGRAM_API_HASH')) as client:
@client.on(events.NewMessage())
async def handler(event):
print(event.message.message)
client.run_until_disconnected()
Expected behavior
I want to get printed the text of received messages
Actual behavior
Locally, it works fine, however on Docker the client.on() function is not triggered!
Traceback
No response
Telethon version
1.35
Python version
3.12
Operating system (including distribution name and version)
Windows 11
Other details
No response
Checklist
- The error is in the library's code, and not in my own.
- I have searched for this issue before posting it and there isn't an open duplicate.
- I ran
pip install -U https://github.com/LonamiWebs/Telethon/archive/v1.zip
and triggered the bug in the latest version.
This is unlikely to be a problem in Telethon. Make sure the client has network access, and that the code is running and not crashing.
I don't use Docker, so I'm unlikely to look into this and I'll be closing the issue. Telethon isn't doing anything fancy to connect to Telegram.
If you still believe it's a problem in Telethon I encourage you to dig further and find out the cause.