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

stuck while start() #4406

Open
3 tasks done
xlccccc opened this issue Jul 8, 2024 · 3 comments
Open
3 tasks done

stuck while start() #4406

xlccccc opened this issue Jul 8, 2024 · 3 comments

Comments

@xlccccc
Copy link

xlccccc commented Jul 8, 2024

Code that causes the issue

import asyncio
from telethon import TelegramClient, errors
import logging
logging.basicConfig(level=logging.DEBUG)
api_id = ''
api_hash = ''
phone_number = ''

client = TelegramClient('session_name', api_id, api_hash)

async def main():
    await client.start(phone=phone_number)
    await client.disconnect()

if __name__ == '__main__':
    asyncio.run(main())

Expected behavior

Telegram received the verification code and successfully logged in after entering it

Actual behavior

Stuck when logging in

Traceback

No response

Telethon version

1.36

Python version

3.9.13

Operating system (including distribution name and version)

Windows 10

Other details

DEBUG:asyncio:Using proactor: IocpProactor
DEBUG:asyncio:Using proactor: IocpProactor
INFO:telethon.network.mtprotosender:Connecting to 149.154.175.57:443/TcpFull...
DEBUG:telethon.network.mtprotosender:Connection attempt 1...
DEBUG:telethon.network.mtprotosender:Connection success!
DEBUG:telethon.network.mtprotosender:Starting send loop
DEBUG:telethon.network.mtprotosender:Starting receive loop
INFO:telethon.network.mtprotosender:Connection to 149.154.175.57:443/TcpFull complete!
DEBUG:telethon.network.mtprotosender:Waiting for messages to send...
DEBUG:telethon.extensions.messagepacker:Assigned msg_id = 7389165337218010064 to InvokeWithLayerRequest (20a66ad8f10)
DEBUG:telethon.network.mtprotosender:Encrypting 1 message(s) in 76 bytes for sending
DEBUG:telethon.network.mtprotosender:Encrypted messages put in a queue to be sent
DEBUG:telethon.network.mtprotosender:Waiting for messages to send...
DEBUG:telethon.network.mtprotosender:Receiving items from the network...
DEBUG:telethon.network.mtprotosender:Handling bad salt for message 7389165337218010064
DEBUG:telethon.network.mtprotosender:1 message(s) will be resent
DEBUG:telethon.network.mtprotosender:Receiving items from the network...

The log is stuck here all the time and no error is reported

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.
@gensx-x1
Copy link

i'm currently having same issue, except im trying to run code on google cloud vm. it works perfectly on my machine, its stuck i same place as yours on vm.

@mortalis13
Copy link

Something going on with the Telegram APIs maybe...
Was receiving the unhelpful Server sent a very new message with ID 7410434973273745413, ignoring (see FAQ for details).

Thanks for the logging hint, getting similar debug logs but a bit more lines...

DEBUG:asyncio:Using proactor: IocpProactor
INFO:telethon.network.mtprotosender:Connecting to 149.154.167.91:443/TcpFull...
DEBUG:telethon.network.mtprotosender:Connection attempt 1...
DEBUG:telethon.network.mtprotosender:Connection success!
DEBUG:telethon.network.mtprotosender:Starting send loop
DEBUG:telethon.network.mtprotosender:Starting receive loop
INFO:telethon.network.mtprotosender:Connection to 149.154.167.91:443/TcpFull complete!
DEBUG:telethon.network.mtprotosender:Waiting for messages to send...
DEBUG:telethon.extensions.messagepacker:Assigned msg_id = 7410435962950057644 to InvokeWithLayerRequest (175b3260810)
DEBUG:telethon.network.mtprotosender:Encrypting 1 message(s) in 76 bytes for sending
DEBUG:telethon.network.mtprotosender:Encrypted messages put in a queue to be sent
DEBUG:telethon.network.mtprotosender:Waiting for messages to send...
DEBUG:telethon.network.mtprotosender:Receiving items from the network...
DEBUG:telethon.network.mtprotosender:Handling bad salt for message 7410435962950057644
DEBUG:telethon.network.mtprotosender:1 message(s) will be resent
DEBUG:telethon.network.mtprotosender:Receiving items from the network...
DEBUG:telethon.extensions.messagepacker:Assigned msg_id = 7410435963239099160 to InvokeWithLayerRequest (175b3260810)
DEBUG:telethon.network.mtprotosender:Encrypting 1 message(s) in 76 bytes for sending
DEBUG:telethon.network.mtprotosender:Encrypted messages put in a queue to be sent
DEBUG:telethon.network.mtprotosender:Waiting for messages to send...
DEBUG:telethon.extensions.messagepacker:Assigned msg_id = 7410435963249613420 to MsgsAck (175af519810)
DEBUG:telethon.network.mtprotosender:Encrypting 1 message(s) in 36 bytes for sending
DEBUG:telethon.network.mtprotosender:Encrypted messages put in a queue to be sent
DEBUG:telethon.network.mtprotosender:Waiting for messages to send...
WARNING:telethon.network.mtprotostate:Server sent a very new message with ID 7410436216796687365, ignoring (see FAQ for details)
DEBUG:telethon.network.mtprotosender:Receiving items from the network...
WARNING:telethon.network.mtprotostate:Server sent a very new message with ID 7410436216857783297, ignoring (see FAQ for details)
DEBUG:telethon.network.mtprotosender:Receiving items from the network...

Running the sync code from the readme basically, posting here for contrast.

from telethon import TelegramClient, events, sync
import logging

logging.basicConfig(level=logging.DEBUG)

api_id = 0
api_hash = '0'

client = TelegramClient('session_name', api_id, api_hash)
client.start()

Steps to reproduce:

  1. Create a venv
  2. pip install telethon
  3. python a.py
  4. Enter credentials
  5. Script ends ok
  6. python a.py
  7. Stuck with the above log

Windows 10
Python 3.11.9
Telethon 1.36.0

@mortalis13
Copy link

Well , basically allowing to go forward after Server sent a very new message... makes the client to work, it seems, at least for getting messages.
Just removed the return None after the message warnings are printed in network /mtprotostate.py

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

3 participants