LonamiWebs / Telethon

Pure Python 3 MTProto API Telegram client library, for bots too!
https://docs.telethon.dev
MIT License
9.9k stars 1.4k forks source link

API authentication not working when requesting server is in a different country #1504

Closed spencescu closed 4 years ago

spencescu commented 4 years ago

I am working on an API application and the code works fine when running on my local machine (in Greece). However, when I install the code on a customer AWS instance (in the US) I never get the login codes. I used my US phone number to sign up for another telegram account and that worked. On the other hand, I am able to log in to telegram web with the Greek number from the US server, so it seems the web app does not have country restrictions, but the API does. Can you please point me to any docs related to this, unless this is a bug?

Checklist

Code that causes the issue

from telethon.sync import TelegramClient
...

Traceback

Traceback (most recent call last):
  File "code.py", line 1, in <code>
Lonami commented 4 years ago

The amount of code or traceback you provided is nowhere enough for anyone to efficiently troubleshoot your issue. Please post all relevant code and the full traceback. You should also make sure to check all 3 checkboxes, not just one (after doing what they say).

MirceaLutic commented 4 years ago

Traceback (most recent call last): File "/home/mircea/.local/lib/python3.6/site-packages/NetScraper.py", line 364, in files = job.run() File "/home/mircea/.local/lib/python3.6/site-packages/NetScraper.py", line 133, in run self.process(link) File "/home/mircea/.local/lib/python3.6/site-packages/NetScraper.py", line 155, in process file = getter.get(link) File "/home/mircea/.local/lib/python3.6/site-packages/WebGetter.py", line 141, in get return self.getUrl(link.buildUrl()) File "/home/mircea/.local/lib/python3.6/site-packages/WebGetter.py", line 152, in getUrl loop.run_until_complete(self.getMessages(url, chat)) File "/usr/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete return future.result() File "/home/mircea/.local/lib/python3.6/site-packages/WebGetter.py", line 159, in getMessages channel = await self.client.get_entity(url) File "/home/mircea/.local/lib/python3.6/site-packages/telethon/client/users.py", line 310, in get_entity result.append(await self._get_entity_from_string(x)) File "/home/mircea/.local/lib/python3.6/site-packages/telethon/client/users.py", line 525, in _get_entity_from_string functions.contacts.ResolveUsernameRequest(username)) File "/home/mircea/.local/lib/python3.6/site-packages/telethon/client/users.py", line 30, in call return await self._call(self._sender, request, ordered=ordered) File "/home/mircea/.local/lib/python3.6/site-packages/telethon/client/users.py", line 77, in _call result = await future telethon.errors.rpcerrorlist.AuthKeyUnregisteredError: The key is not registered in the system (caused by ResolveUsernameRequest)

MirceaLutic commented 4 years ago

This time I probably tried to use a code that was for another session

MirceaLutic commented 4 years ago

Usually I just don't get any code. Here is my routine:

async def coro_sign_in(self):
    try:
        await self.client.connect()
        if not self.client.is_connected():
            await asyncio.sleep(1)

        ok = await self.client.is_user_authorized()
        if ok:
            return True
        phone = input("Enter phone:")
        await self.client.send_code_request(phone)
        login = input('Login code :')
        await self.client.sign_in(phone, login)
    except:  # catch *all* exceptions
        self.print_error(sys.exc_info()[0])
        return False
        # self.client.sign_in(password=pwd)
MirceaLutic commented 4 years ago

So the problem is that I never get any code with await self.client.send_code_request(phone)

MirceaLutic commented 4 years ago

That only happens when the server is in another country

MirceaLutic commented 4 years ago

It's an aws vm

Lonami commented 4 years ago

1448.

MirceaLutic commented 4 years ago

When I run it on Windows+python3.4 or WSL+python3.2 on my own laptop everything works ok

MirceaLutic commented 4 years ago

What's the meaning of telethon.errors.rpcerrorlist.AuthKeyUnregisteredError ?

Lonami commented 4 years ago

Not yet logged in.

spencescu commented 4 years ago

Question - does the code handle these errors from

https://core.telegram.org/method/auth.sendCode

303 NETWORK_MIGRATE_X Repeat the query to data-center X
303 PHONE_MIGRATE_X Repeat the query to data-center X

My guess is that if we try with country x phone # on a server in country y we may be redirected to a different DC but the client is not able to do that or return a meaningful error and it just hangs...

MirceaLutic commented 4 years ago

Is it possible that the problem may be due to incomplete processing of redirections to a different data center like

303 | NETWORK_MIGRATE_X | Repeat the query to data-center X 303 | PHONE_MIGRATE_X | Repeat the query to data-center X

See https://core.telegram.org/method/auth.sendCode

Lonami commented 4 years ago

https://github.com/LonamiWebs/Telethon/blob/012cae051bc0a5a63f0dec8efe47b7a6501b74e2/telethon/client/users.py#L105

MirceaLutic commented 4 years ago

The whole point is to use another DC for authentication It doesn't look like this is done in user.py

Lonami commented 4 years ago

It is done. A few lines below you can see a call to switch_dc. It is also logged so you can see if this is the case.

MirceaLutic commented 4 years ago

await self._switch_dc(e.new_dc) does not seem to be defined and is probably not reached

In my understanding: should_raise = isinstance(e, (errors.PhoneMigrateError, errors.NetworkMigrateError))

should_raise appears to be True

            if should_raise and await self.is_user_authorized():
                raise # raise if is_user_authorized ?
            await self._switch_dc(e.new_dc)  # is this reached? where is it defined?
Lonami commented 4 years ago

does not seem to be defined

"Not seem" is not an option. It is defined in the other classes since this is only partial with some methods. If you don't see the "not defined" error it is obviously defined.

Should raise only raises if the account is logged in, and we're saying it's not logged in yet.

MirceaLutic commented 4 years ago

Well, it does not seem to get the authorisation from the new dc.

MirceaLutic commented 4 years ago

It should send the code request to the new dc But the code never gets sent

MirceaLutic commented 4 years ago

So it looks like the code request does not reach the new dc

MirceaLutic commented 4 years ago

In order to reproduce this you need to run hello.py on a server that is on the other side of the world from where the account was registered so you get a different dc to authorise with

spencescu commented 4 years ago

That is correct. The hello.py on a US based AWS server works perfect with a US phone # and never gets the login code with a Greek one. However, I can log in to the telegram browser app on the same machine with the Greek number with no issues.

MirceaLutic commented 4 years ago

I guess this issue is valid and actionable and needs to be reopened.

Lonami commented 4 years ago

Do the logs indicate that phone or network migration is raised? If not how are we supposed to know which is the home DC?

spencescu commented 4 years ago

Nothing gets logged. It just hangs.

spencescu commented 4 years ago

@Lonami it would be great if you could do the test suggested by @MirceaLutic, if you need any help we can use US test servers and gather whatever you need in terms of logs... It seems a lot of people have this issue, it would be nice to solve it.

MirceaLutic commented 4 years ago

I guess the best way to do it is run hello.py on the local IDE with a US phone number

Lonami commented 4 years ago

Running locally, when Telethon by default connects to a datacenter different to the one my account is on:

``` [DEBUG/2020-07-28 18:59:53,658] asyncio: Using selector: EpollSelector [ INFO/2020-07-28 18:59:53,670] telethon.network.mtprotosender: Connecting to 149.154.167.51:443/TcpFull... [DEBUG/2020-07-28 18:59:53,670] telethon.network.mtprotosender: Connection attempt 1... [DEBUG/2020-07-28 18:59:53,723] telethon.network.mtprotosender: Connection success! [DEBUG/2020-07-28 18:59:53,723] telethon.network.mtprotosender: New auth_key attempt 1... [DEBUG/2020-07-28 18:59:54,411] telethon.network.mtprotosender: auth_key generation success! [DEBUG/2020-07-28 18:59:54,411] telethon.network.mtprotosender: Starting send loop [DEBUG/2020-07-28 18:59:54,411] telethon.network.mtprotosender: Starting receive loop [ INFO/2020-07-28 18:59:54,411] telethon.network.mtprotosender: Connection to 149.154.167.51:443/TcpFull complete! [DEBUG/2020-07-28 18:59:54,412] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 18:59:54,412] telethon.extensions.messagepacker: Assigned msg_id = 6854577096632391436 to InvokeWithLayerRequest (7f041caa5af0) [DEBUG/2020-07-28 18:59:54,412] telethon.network.mtprotosender: Encrypting 1 message(s) in 84 bytes for sending [DEBUG/2020-07-28 18:59:54,412] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 18:59:54,412] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 18:59:54,413] telethon.network.mtprotosender: Receiving items from the network... [DEBUG/2020-07-28 18:59:54,473] telethon.network.mtprotosender: Handling bad salt for message 6854577096632391436 [DEBUG/2020-07-28 18:59:54,473] telethon.network.mtprotosender: 1 message(s) will be resent [DEBUG/2020-07-28 18:59:54,473] telethon.network.mtprotosender: Receiving items from the network... [DEBUG/2020-07-28 18:59:54,473] telethon.extensions.messagepacker: Assigned msg_id = 6854577096878868564 to InvokeWithLayerRequest (7f041caa5af0) [DEBUG/2020-07-28 18:59:54,474] telethon.network.mtprotosender: Encrypting 1 message(s) in 84 bytes for sending [DEBUG/2020-07-28 18:59:54,474] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 18:59:54,474] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 18:59:54,475] telethon.extensions.messagepacker: Assigned msg_id = 6854577096883146744 to MsgsAck (7f041caa5f10) [DEBUG/2020-07-28 18:59:54,475] telethon.network.mtprotosender: Encrypting 1 message(s) in 36 bytes for sending [DEBUG/2020-07-28 18:59:54,475] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 18:59:54,476] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 18:59:54,530] telethon.network.mtprotosender: Handling container [DEBUG/2020-07-28 18:59:54,530] telethon.network.mtprotosender: Handling new session created [DEBUG/2020-07-28 18:59:54,530] telethon.network.mtprotosender: Handling acknowledge for [6854577096878868564] [DEBUG/2020-07-28 18:59:54,530] telethon.network.mtprotosender: Receiving items from the network... [DEBUG/2020-07-28 18:59:54,535] telethon.network.mtprotosender: Handling RPC result for message 6854577096878868564 [DEBUG/2020-07-28 18:59:54,537] telethon.network.mtprotosender: Receiving items from the network... [DEBUG/2020-07-28 18:59:54,537] telethon.extensions.messagepacker: Assigned msg_id = 6854577097134673580 to GetStateRequest (7f041caa5af0) [DEBUG/2020-07-28 18:59:54,538] telethon.network.mtprotosender: Encrypting 1 message(s) in 20 bytes for sending [DEBUG/2020-07-28 18:59:54,538] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 18:59:54,538] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 18:59:54,538] telethon.extensions.messagepacker: Assigned msg_id = 6854577097138868792 to MsgsAck (7f041caa5c10) [DEBUG/2020-07-28 18:59:54,539] telethon.network.mtprotosender: Encrypting 1 message(s) in 60 bytes for sending [DEBUG/2020-07-28 18:59:54,540] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 18:59:54,540] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 18:59:54,594] telethon.network.mtprotosender: Handling RPC result for message 6854577097134673580 [DEBUG/2020-07-28 18:59:54,594] telethon.network.mtprotosender: Receiving items from the network... [DEBUG/2020-07-28 18:59:54,595] telethon.extensions.messagepacker: Assigned msg_id = 6854577097363212092 to MsgsAck (7f041cabb250) [DEBUG/2020-07-28 18:59:54,595] telethon.network.mtprotosender: Encrypting 1 message(s) in 36 bytes for sending [DEBUG/2020-07-28 18:59:54,595] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 18:59:54,596] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 18:59:54,596] telethon.extensions.messagepacker: Assigned msg_id = 6854577097367781144 to MsgsAck (7f041caa5ca0) [DEBUG/2020-07-28 18:59:54,596] telethon.network.mtprotosender: Encrypting 1 message(s) in 36 bytes for sending Please enter your phone (or bot token): [DEBUG/2020-07-28 19:00:04,661] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 19:00:04,661] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 19:00:04,661] telethon.extensions.messagepacker: Assigned msg_id = 6854577140579540972 to SendCodeRequest (7f041cabb0a0) [DEBUG/2020-07-28 19:00:04,661] telethon.network.mtprotosender: Encrypting 1 message(s) in 80 bytes for sending [DEBUG/2020-07-28 19:00:04,662] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 19:00:04,662] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 19:00:04,812] telethon.network.mtprotosender: Handling RPC result for message 6854577140579540972 [DEBUG/2020-07-28 19:00:04,816] telethon.network.mtprotosender: Receiving items from the network... [DEBUG/2020-07-28 19:00:04,816] telethon.extensions.messagepacker: Assigned msg_id = 6854577141198797948 to MsgsAck (7f041caa5a60) [DEBUG/2020-07-28 19:00:04,816] telethon.network.mtprotosender: Encrypting 1 message(s) in 36 bytes for sending [DEBUG/2020-07-28 19:00:04,817] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 19:00:04,817] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 19:00:04,817] telethon.extensions.messagepacker: Assigned msg_id = 6854577141202230220 to MsgsAck (7f041cabb7c0) [DEBUG/2020-07-28 19:00:04,817] telethon.network.mtprotosender: Encrypting 1 message(s) in 36 bytes for sending [ INFO/2020-07-28 19:00:04,817] telethon.client.users: Phone migrated to 4 [ INFO/2020-07-28 19:00:04,817] telethon.client.telegrambaseclient: Reconnecting to new data center 4 [DEBUG/2020-07-28 19:00:04,817] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 19:00:04,817] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 19:00:04,817] telethon.extensions.messagepacker: Assigned msg_id = 6854577141204581980 to GetConfigRequest (7f041cabbca0) [DEBUG/2020-07-28 19:00:04,817] telethon.network.mtprotosender: Encrypting 1 message(s) in 20 bytes for sending [DEBUG/2020-07-28 19:00:04,818] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 19:00:04,818] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 19:00:04,956] telethon.network.mtprotosender: Handling RPC result for message 6854577141204581980 [DEBUG/2020-07-28 19:00:04,957] telethon.network.mtprotosender: Receiving items from the network... [ INFO/2020-07-28 19:00:04,957] telethon.network.mtprotosender: Disconnecting from 149.154.167.51:443/TcpFull... [DEBUG/2020-07-28 19:00:04,957] telethon.network.mtprotosender: Closing current connection... [DEBUG/2020-07-28 19:00:04,958] telethon.network.mtprotosender: Cancelling 0 pending message(s)... [ INFO/2020-07-28 19:00:04,959] telethon.network.mtprotosender: Disconnection from 149.154.167.51:443/TcpFull complete! [ INFO/2020-07-28 19:00:04,959] telethon.network.mtprotosender: Connecting to 149.154.167.92:443/TcpFull... [DEBUG/2020-07-28 19:00:04,959] telethon.network.mtprotosender: Connection attempt 1... [DEBUG/2020-07-28 19:00:05,008] telethon.network.mtprotosender: Connection success! [DEBUG/2020-07-28 19:00:05,009] telethon.network.mtprotosender: New auth_key attempt 1... [DEBUG/2020-07-28 19:00:05,607] telethon.network.mtprotosender: auth_key generation success! [DEBUG/2020-07-28 19:00:05,607] telethon.network.mtprotosender: Starting send loop [DEBUG/2020-07-28 19:00:05,607] telethon.network.mtprotosender: Starting receive loop [ INFO/2020-07-28 19:00:05,607] telethon.network.mtprotosender: Connection to 149.154.167.92:443/TcpFull complete! [DEBUG/2020-07-28 19:00:05,608] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 19:00:05,608] telethon.extensions.messagepacker: Assigned msg_id = 6854577141204581984 to InvokeWithLayerRequest (7f041cabbdf0) [DEBUG/2020-07-28 19:00:05,608] telethon.extensions.messagepacker: Assigned msg_id = 6854577141204581988 to MsgsAck (7f041cabbb80) [DEBUG/2020-07-28 19:00:05,608] telethon.network.mtprotosender: Encrypting 2 message(s) in 144 bytes for sending [DEBUG/2020-07-28 19:00:05,609] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 19:00:05,609] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 19:00:05,609] telethon.network.mtprotosender: Receiving items from the network... [DEBUG/2020-07-28 19:00:05,662] telethon.network.mtprotosender: Handling bad salt for message 6854577141204581992 [DEBUG/2020-07-28 19:00:05,663] telethon.network.mtprotosender: 1 message(s) will be resent [DEBUG/2020-07-28 19:00:05,663] telethon.network.mtprotosender: Receiving items from the network... [DEBUG/2020-07-28 19:00:05,663] telethon.extensions.messagepacker: Assigned msg_id = 6854577141204581996 to InvokeWithLayerRequest (7f041cabbdf0) [DEBUG/2020-07-28 19:00:05,663] telethon.network.mtprotosender: Encrypting 1 message(s) in 84 bytes for sending [DEBUG/2020-07-28 19:00:05,664] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 19:00:05,664] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 19:00:05,664] telethon.extensions.messagepacker: Assigned msg_id = 6854577141204582000 to MsgsAck (7f041cad1190) [DEBUG/2020-07-28 19:00:05,664] telethon.network.mtprotosender: Encrypting 1 message(s) in 36 bytes for sending [DEBUG/2020-07-28 19:00:05,665] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 19:00:05,665] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 19:00:05,734] telethon.network.mtprotosender: Handling container [DEBUG/2020-07-28 19:00:05,734] telethon.network.mtprotosender: Handling new session created [DEBUG/2020-07-28 19:00:05,734] telethon.network.mtprotosender: Handling acknowledge for [6854577141204581996] [DEBUG/2020-07-28 19:00:05,734] telethon.network.mtprotosender: Receiving items from the network... [DEBUG/2020-07-28 19:00:05,754] telethon.network.mtprotosender: Handling RPC result for message 6854577141204581996 [DEBUG/2020-07-28 19:00:05,755] telethon.network.mtprotosender: Receiving items from the network... [DEBUG/2020-07-28 19:00:05,755] telethon.extensions.messagepacker: Assigned msg_id = 6854577141204582004 to SendCodeRequest (7f041cabb0a0) [DEBUG/2020-07-28 19:00:05,755] telethon.network.mtprotosender: Encrypting 1 message(s) in 80 bytes for sending [DEBUG/2020-07-28 19:00:05,756] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 19:00:05,756] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 19:00:05,756] telethon.extensions.messagepacker: Assigned msg_id = 6854577141204582008 to MsgsAck (7f041cabbb50) [DEBUG/2020-07-28 19:00:05,756] telethon.network.mtprotosender: Encrypting 1 message(s) in 60 bytes for sending [DEBUG/2020-07-28 19:00:05,757] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 19:00:05,757] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 19:00:05,839] telethon.network.mtprotosender: Handling RPC result for message 6854577141204582004 [DEBUG/2020-07-28 19:00:05,840] telethon.network.mtprotosender: Receiving items from the network... Please enter the code you received: ^C ... KeyboardInterrupt ```

Note in particular:

[ INFO/2020-07-28 19:00:04,817] telethon.client.users: Phone migrated to 4
[ INFO/2020-07-28 19:00:04,817] telethon.client.telegrambaseclient: Reconnecting to new data center 4

So automatic reconnection to a different datacenter as needed is being handled correctly, as I imagined. The code did arrive to Telegram and I could've logged in just fine. The AWS issue seems different. "It gets stuck" is not helpful. I would need to find where and how it gets stuck.

I will reopen the AWS issue because there might be a way to do it, but I doubt I'll look into it. It's simpler to just give it an already-logged-in session, and there are more services out there.

If you both are going to discuss the issue further, please avoid spamming it with so many comments. This is not instant messaging, the replies can be longer and better thought-out.

spencescu commented 4 years ago

how can i get this level of logging?

spencescu commented 4 years ago
log ``` python3 hello.py [ INFO/2020-07-28 20:30:11,332] telethon.crypto.aes: libssl detected, it will be used for encryption [DEBUG/2020-07-28 20:30:11,607] asyncio: Using selector: EpollSelector [ INFO/2020-07-28 20:30:11,613] telethon.network.mtprotosender: Connecting to 149.154.175.59:443/TcpFull... [DEBUG/2020-07-28 20:30:11,614] telethon.network.mtprotosender: Connection attempt 1... [DEBUG/2020-07-28 20:30:11,644] telethon.network.mtprotosender: Connection success! [DEBUG/2020-07-28 20:30:11,644] telethon.network.mtprotosender: Starting send loop [DEBUG/2020-07-28 20:30:11,644] telethon.network.mtprotosender: Starting receive loop [ INFO/2020-07-28 20:30:11,644] telethon.network.mtprotosender: Connection to 149.154.175.59:443/TcpFull complete! [DEBUG/2020-07-28 20:30:11,650] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 20:30:11,651] telethon.extensions.messagepacker: Assigned msg_id = 6854584888657711536 to InvokeWithLayerRequest (7f373cd1b850) [DEBUG/2020-07-28 20:30:11,651] telethon.network.mtprotosender: Encrypting 1 message(s) in 100 bytes for sending [DEBUG/2020-07-28 20:30:11,651] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 20:30:11,651] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 20:30:11,651] telethon.network.mtprotosender: Receiving items from the network... [DEBUG/2020-07-28 20:30:11,681] telethon.network.mtprotosender: Handling bad salt for message 6854584888657711536 [DEBUG/2020-07-28 20:30:11,682] telethon.network.mtprotosender: 1 message(s) will be resent [DEBUG/2020-07-28 20:30:11,682] telethon.network.mtprotosender: Receiving items from the network... [DEBUG/2020-07-28 20:30:11,682] telethon.extensions.messagepacker: Assigned msg_id = 6854584888784052404 to InvokeWithLayerRequest (7f373cd1b850) [DEBUG/2020-07-28 20:30:11,682] telethon.network.mtprotosender: Encrypting 1 message(s) in 100 bytes for sending [DEBUG/2020-07-28 20:30:11,683] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 20:30:11,683] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 20:30:11,683] telethon.extensions.messagepacker: Assigned msg_id = 6854584888787641080 to MsgsAck (7f373cd1b9d0) [DEBUG/2020-07-28 20:30:11,683] telethon.network.mtprotosender: Encrypting 1 message(s) in 36 bytes for sending [DEBUG/2020-07-28 20:30:11,683] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 20:30:11,684] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 20:30:11,713] telethon.network.mtprotosender: Handling container [DEBUG/2020-07-28 20:30:11,713] telethon.network.mtprotosender: Handling new session created [DEBUG/2020-07-28 20:30:11,713] telethon.network.mtprotosender: Handling acknowledge for [6854584888784052404] [DEBUG/2020-07-28 20:30:11,714] telethon.network.mtprotosender: Receiving items from the network... [DEBUG/2020-07-28 20:30:11,725] telethon.network.mtprotosender: Handling RPC result for message 6854584888784052404 [DEBUG/2020-07-28 20:30:11,725] telethon.network.mtprotosender: Receiving items from the network... [DEBUG/2020-07-28 20:30:11,726] telethon.extensions.messagepacker: Assigned msg_id = 6854584888958045512 to GetStateRequest (7f373cd1b850) [DEBUG/2020-07-28 20:30:11,726] telethon.network.mtprotosender: Encrypting 1 message(s) in 20 bytes for sending [DEBUG/2020-07-28 20:30:11,729] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 20:30:11,729] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 20:30:11,729] telethon.extensions.messagepacker: Assigned msg_id = 6854584888971356900 to MsgsAck (7f373cd1be10) [DEBUG/2020-07-28 20:30:11,729] telethon.network.mtprotosender: Encrypting 1 message(s) in 60 bytes for sending [DEBUG/2020-07-28 20:30:11,729] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 20:30:11,729] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 20:30:11,769] telethon.network.mtprotosender: Handling RPC result for message 6854584888958045512 [DEBUG/2020-07-28 20:30:11,769] telethon.network.mtprotosender: Receiving items from the network... [DEBUG/2020-07-28 20:30:11,769] telethon.extensions.messagepacker: Assigned msg_id = 6854584889131627592 to MsgsAck (7f373cd9eb90) [DEBUG/2020-07-28 20:30:11,769] telethon.network.mtprotosender: Encrypting 1 message(s) in 36 bytes for sending [DEBUG/2020-07-28 20:30:11,769] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 20:30:11,769] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 20:30:11,769] telethon.extensions.messagepacker: Assigned msg_id = 6854584889133066684 to MsgsAck (7f373cd1bc90) [DEBUG/2020-07-28 20:30:11,769] telethon.network.mtprotosender: Encrypting 1 message(s) in 36 bytes for sending Please enter your phone (or bot token): +306946652116 [DEBUG/2020-07-28 20:30:22,951] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 20:30:22,951] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 20:30:22,951] telethon.extensions.messagepacker: Assigned msg_id = 6854584937105223116 to SendCodeRequest (7f373cd34210) [DEBUG/2020-07-28 20:30:22,951] telethon.network.mtprotosender: Encrypting 1 message(s) in 84 bytes for sending [DEBUG/2020-07-28 20:30:22,952] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 20:30:22,952] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 20:30:23,010] telethon.network.mtprotosender: Handling RPC result for message 6854584937105223116 [DEBUG/2020-07-28 20:30:23,011] telethon.network.mtprotosender: Receiving items from the network... [DEBUG/2020-07-28 20:30:23,011] telethon.extensions.messagepacker: Assigned msg_id = 6854584937640585956 to MsgsAck (7f373cda2410) [DEBUG/2020-07-28 20:30:23,011] telethon.network.mtprotosender: Encrypting 1 message(s) in 36 bytes for sending [DEBUG/2020-07-28 20:30:23,012] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 20:30:23,012] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 20:30:23,012] telethon.extensions.messagepacker: Assigned msg_id = 6854584937641957340 to MsgsAck (7f373cd1bd90) [DEBUG/2020-07-28 20:30:23,012] telethon.network.mtprotosender: Encrypting 1 message(s) in 36 bytes for sending [ INFO/2020-07-28 20:30:23,012] telethon.client.users: Phone migrated to 4 [ INFO/2020-07-28 20:30:23,012] telethon.client.telegrambaseclient: Reconnecting to new data center 4 [DEBUG/2020-07-28 20:30:23,012] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 20:30:23,012] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 20:30:23,012] telethon.extensions.messagepacker: Assigned msg_id = 6854584937644313868 to GetConfigRequest (7f373cd34490) [DEBUG/2020-07-28 20:30:23,012] telethon.network.mtprotosender: Encrypting 1 message(s) in 20 bytes for sending [DEBUG/2020-07-28 20:30:23,012] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 20:30:23,013] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 20:30:23,066] telethon.network.mtprotosender: Handling RPC result for message 6854584937644313868 [DEBUG/2020-07-28 20:30:23,066] telethon.network.mtprotosender: Receiving items from the network... [ INFO/2020-07-28 20:30:23,071] telethon.network.mtprotosender: Disconnecting from 149.154.175.59:443/TcpFull... [DEBUG/2020-07-28 20:30:23,071] telethon.network.mtprotosender: Closing current connection... [DEBUG/2020-07-28 20:30:23,071] telethon.network.mtprotosender: Cancelling 0 pending message(s)... [ INFO/2020-07-28 20:30:23,072] telethon.network.mtprotosender: Disconnection from 149.154.175.59:443/TcpFull complete! [ INFO/2020-07-28 20:30:23,072] telethon.network.mtprotosender: Connecting to 149.154.167.92:443/TcpFull... [DEBUG/2020-07-28 20:30:23,072] telethon.network.mtprotosender: Connection attempt 1... [DEBUG/2020-07-28 20:30:23,156] telethon.network.mtprotosender: Connection success! [DEBUG/2020-07-28 20:30:23,156] telethon.network.mtprotosender: New auth_key attempt 1... [DEBUG/2020-07-28 20:30:23,752] telethon.network.mtprotosender: auth_key generation success! [DEBUG/2020-07-28 20:30:23,752] telethon.network.mtprotosender: Starting send loop [DEBUG/2020-07-28 20:30:23,752] telethon.network.mtprotosender: Starting receive loop [ INFO/2020-07-28 20:30:23,752] telethon.network.mtprotosender: Connection to 149.154.167.92:443/TcpFull complete! [DEBUG/2020-07-28 20:30:23,758] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 20:30:23,758] telethon.extensions.messagepacker: Assigned msg_id = 6854584940628786144 to InvokeWithLayerRequest (7f373cabc290) [DEBUG/2020-07-28 20:30:23,758] telethon.extensions.messagepacker: Assigned msg_id = 6854584940629150448 to MsgsAck (7f373cabc5d0) [DEBUG/2020-07-28 20:30:23,759] telethon.network.mtprotosender: Encrypting 2 message(s) in 160 bytes for sending [DEBUG/2020-07-28 20:30:23,759] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 20:30:23,759] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 20:30:23,759] telethon.network.mtprotosender: Receiving items from the network... [DEBUG/2020-07-28 20:30:23,844] telethon.network.mtprotosender: Handling bad salt for message 6854584940629460392 [DEBUG/2020-07-28 20:30:23,844] telethon.network.mtprotosender: 1 message(s) will be resent [DEBUG/2020-07-28 20:30:23,844] telethon.network.mtprotosender: Receiving items from the network... [DEBUG/2020-07-28 20:30:23,844] telethon.extensions.messagepacker: Assigned msg_id = 6854584940970800456 to InvokeWithLayerRequest (7f373cabc290) [DEBUG/2020-07-28 20:30:23,844] telethon.network.mtprotosender: Encrypting 1 message(s) in 100 bytes for sending [DEBUG/2020-07-28 20:30:23,844] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 20:30:23,844] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 20:30:23,844] telethon.extensions.messagepacker: Assigned msg_id = 6854584940972355900 to MsgsAck (7f373cd34710) [DEBUG/2020-07-28 20:30:23,844] telethon.network.mtprotosender: Encrypting 1 message(s) in 36 bytes for sending [DEBUG/2020-07-28 20:30:23,844] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 20:30:23,845] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 20:30:23,929] telethon.network.mtprotosender: Handling container [DEBUG/2020-07-28 20:30:23,929] telethon.network.mtprotosender: Handling new session created [DEBUG/2020-07-28 20:30:23,929] telethon.network.mtprotosender: Handling acknowledge for [6854584940970800456] [DEBUG/2020-07-28 20:30:23,929] telethon.network.mtprotosender: Receiving items from the network... [DEBUG/2020-07-28 20:30:23,938] telethon.network.mtprotosender: Handling RPC result for message 6854584940970800456 [DEBUG/2020-07-28 20:30:23,939] telethon.network.mtprotosender: Receiving items from the network... [DEBUG/2020-07-28 20:30:23,939] telethon.extensions.messagepacker: Assigned msg_id = 6854584941351484356 to SendCodeRequest (7f373cd34210) [DEBUG/2020-07-28 20:30:23,939] telethon.network.mtprotosender: Encrypting 1 message(s) in 84 bytes for sending [DEBUG/2020-07-28 20:30:23,939] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 20:30:23,939] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 20:30:23,939] telethon.extensions.messagepacker: Assigned msg_id = 6854584941353158056 to MsgsAck (7f373cabc490) [DEBUG/2020-07-28 20:30:23,939] telethon.network.mtprotosender: Encrypting 1 message(s) in 60 bytes for sending [DEBUG/2020-07-28 20:30:23,940] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-28 20:30:23,940] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-28 20:30:24,059] telethon.network.mtprotosender: Handling RPC result for message 6854584941351484356 [DEBUG/2020-07-28 20:30:24,059] telethon.network.mtprotosender: Receiving items from the network... Please enter the code you received: ^CTraceback (most recent call last): File "hello.py", line 13, in with TelegramClient('anon', api_id, api_hash) as client: File "/usr/local/lib64/python3.7/site-packages/telethon/helpers.py", line 163, in _sync_enter return loop.run_until_complete(self.__aenter__()) File "/usr/lib64/python3.7/asyncio/base_events.py", line 570, in run_until_complete self.run_forever() File "/usr/lib64/python3.7/asyncio/base_events.py", line 538, in run_forever self._run_once() File "/usr/lib64/python3.7/asyncio/base_events.py", line 1782, in _run_once handle._run() File "/usr/lib64/python3.7/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/usr/local/lib64/python3.7/site-packages/telethon/client/auth.py", line 673, in __aenter__ return await self.start() File "/usr/local/lib64/python3.7/site-packages/telethon/client/auth.py", line 170, in _start value = code_callback() File "/usr/local/lib64/python3.7/site-packages/telethon/client/auth.py", line 106, in code_callback return input('Please enter the code you received: ') KeyboardInterrupt ```
Lonami commented 4 years ago

It's also reconnecting properly and sending the request:

[ INFO/2020-07-28 20:30:23,012] telethon.client.users: Phone migrated to 4
[ INFO/2020-07-28 20:30:23,012] telethon.client.telegrambaseclient: Reconnecting to new data center 4
...
[ INFO/2020-07-28 20:30:23,071] telethon.network.mtprotosender: Disconnecting from 149.154.175.59:443/TcpFull...
[DEBUG/2020-07-28 20:30:23,071] telethon.network.mtprotosender: Closing current connection...
[DEBUG/2020-07-28 20:30:23,071] telethon.network.mtprotosender: Cancelling 0 pending message(s)...
[ INFO/2020-07-28 20:30:23,072] telethon.network.mtprotosender: Disconnection from 149.154.175.59:443/TcpFull complete!
[ INFO/2020-07-28 20:30:23,072] telethon.network.mtprotosender: Connecting to 149.154.167.92:443/TcpFull...
[DEBUG/2020-07-28 20:30:23,072] telethon.network.mtprotosender: Connection attempt 1...
[DEBUG/2020-07-28 20:30:23,156] telethon.network.mtprotosender: Connection success!
...
[DEBUG/2020-07-28 20:30:23,939] telethon.extensions.messagepacker: Assigned msg_id = 6854584941351484356 to SendCodeRequest (7f373cd34210)
...
[DEBUG/2020-07-28 20:30:24,059] telethon.network.mtprotosender: Handling RPC result for message 6854584941351484356

Most likely AWS is blocked, as it was said in the other issue a while ago. The library handles reconnections just fine. If you figure out how to make it work in AWS make sure to let everyone know in the other issue.

spencescu commented 4 years ago

It works just fine in AWS with a US number, I don't believe anything is blocked.

MirceaLutic commented 4 years ago

@Lonami So what you are saying is that AWS is only blocking the connection to the new dc ? This seems highly unlikely to me. I would rather assume that the new dc sees the code request as somehow invalid or incomplete. Do you get any kind of response on sending the code request? Can you spot it in the log?

Lonami commented 4 years ago

The snippet I copied from @spencescu shows that it reconnects, re-sends the request and gets a response. If it didn't get a response it would never ask "enter code". The request is executed fine and a response arrives but Telegram does not actually send the code.

MirceaLutic commented 4 years ago

Could the response actually contain some error condition? It may be useful to log that response

spencescu commented 4 years ago

Also, how do we explain that it is working fine with a local number but not with a foreign one?

Lonami commented 4 years ago

It may be useful to log that response

It would leak private information which is why it's not logged. You can use the raw request and print it on your own.

spencescu commented 4 years ago

For what is worth, here is a happy path log. Note there is no data center switch...

``` python3 hello.py [ INFO/2020-07-31 16:37:24,495] telethon.crypto.aes: libssl detected, it will be used for encryption [DEBUG/2020-07-31 16:37:24,653] asyncio: Using selector: EpollSelector [ INFO/2020-07-31 16:37:24,658] telethon.network.mtprotosender: Connecting to 149.154.175.58:443/TcpFull... [DEBUG/2020-07-31 16:37:24,658] telethon.network.mtprotosender: Connection attempt 1... [DEBUG/2020-07-31 16:37:24,699] telethon.network.mtprotosender: Connection success! [DEBUG/2020-07-31 16:37:24,699] telethon.network.mtprotosender: Starting send loop [DEBUG/2020-07-31 16:37:24,699] telethon.network.mtprotosender: Starting receive loop [ INFO/2020-07-31 16:37:24,699] telethon.network.mtprotosender: Connection to 149.154.175.58:443/TcpFull complete! [DEBUG/2020-07-31 16:37:24,704] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-31 16:37:24,704] telethon.extensions.messagepacker: Assigned msg_id = 6855684542234706956 to InvokeWithLayerRequest (7f357c5510b8) [DEBUG/2020-07-31 16:37:24,704] telethon.network.mtprotosender: Encrypting 1 message(s) in 84 bytes for sending [DEBUG/2020-07-31 16:37:24,705] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-31 16:37:24,705] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-31 16:37:24,705] telethon.network.mtprotosender: Receiving items from the network... [DEBUG/2020-07-31 16:37:24,748] telethon.network.mtprotosender: Handling bad salt for message 6855684542234706956 [DEBUG/2020-07-31 16:37:24,748] telethon.network.mtprotosender: 1 message(s) will be resent [DEBUG/2020-07-31 16:37:24,748] telethon.network.mtprotosender: Receiving items from the network... [DEBUG/2020-07-31 16:37:24,748] telethon.extensions.messagepacker: Assigned msg_id = 6855684542410218316 to InvokeWithLayerRequest (7f357c5510b8) [DEBUG/2020-07-31 16:37:24,748] telethon.network.mtprotosender: Encrypting 1 message(s) in 84 bytes for sending [DEBUG/2020-07-31 16:37:24,748] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-31 16:37:24,749] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-31 16:37:24,749] telethon.extensions.messagepacker: Assigned msg_id = 6855684542411871036 to MsgsAck (7f357c535eb8) [DEBUG/2020-07-31 16:37:24,749] telethon.network.mtprotosender: Encrypting 1 message(s) in 36 bytes for sending [DEBUG/2020-07-31 16:37:24,749] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-31 16:37:24,749] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-31 16:37:24,790] telethon.network.mtprotosender: Handling container [DEBUG/2020-07-31 16:37:24,790] telethon.network.mtprotosender: Handling new session created [DEBUG/2020-07-31 16:37:24,790] telethon.network.mtprotosender: Handling acknowledge for [6855684542410218316] [DEBUG/2020-07-31 16:37:24,790] telethon.network.mtprotosender: Receiving items from the network... [DEBUG/2020-07-31 16:37:24,799] telethon.network.mtprotosender: Handling RPC result for message 6855684542410218316 [DEBUG/2020-07-31 16:37:24,799] telethon.network.mtprotosender: Receiving items from the network... [DEBUG/2020-07-31 16:37:24,799] telethon.extensions.messagepacker: Assigned msg_id = 6855684542615238268 to GetStateRequest (7f357c5514e0) [DEBUG/2020-07-31 16:37:24,800] telethon.network.mtprotosender: Encrypting 1 message(s) in 20 bytes for sending [DEBUG/2020-07-31 16:37:24,800] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-31 16:37:24,800] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-31 16:37:24,800] telethon.extensions.messagepacker: Assigned msg_id = 6855684542616985400 to MsgsAck (7f357c5514a8) [DEBUG/2020-07-31 16:37:24,800] telethon.network.mtprotosender: Encrypting 1 message(s) in 60 bytes for sending [DEBUG/2020-07-31 16:37:24,800] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-31 16:37:24,800] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-31 16:37:24,846] telethon.network.mtprotosender: Handling RPC result for message 6855684542615238268 [DEBUG/2020-07-31 16:37:24,846] telethon.network.mtprotosender: Receiving items from the network... [DEBUG/2020-07-31 16:37:24,846] telethon.extensions.messagepacker: Assigned msg_id = 6855684542801420292 to MsgsAck (7f357c551518) [DEBUG/2020-07-31 16:37:24,846] telethon.network.mtprotosender: Encrypting 1 message(s) in 36 bytes for sending [DEBUG/2020-07-31 16:37:24,846] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-31 16:37:24,846] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-31 16:37:24,846] telethon.extensions.messagepacker: Assigned msg_id = 6855684542802898484 to MsgsAck (7f357c551668) [DEBUG/2020-07-31 16:37:24,846] telethon.network.mtprotosender: Encrypting 1 message(s) in 36 bytes for sending Please enter your phone (or bot token): +19174957115 [DEBUG/2020-07-31 16:37:34,350] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-31 16:37:34,350] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-31 16:37:34,350] telethon.extensions.messagepacker: Assigned msg_id = 6855684583767656664 to SendCodeRequest (7f357c5517f0) [DEBUG/2020-07-31 16:37:34,350] telethon.network.mtprotosender: Encrypting 1 message(s) in 80 bytes for sending [DEBUG/2020-07-31 16:37:34,350] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-31 16:37:34,351] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-31 16:37:34,431] telethon.network.mtprotosender: Handling RPC result for message 6855684583767656664 [DEBUG/2020-07-31 16:37:34,431] telethon.network.mtprotosender: Receiving items from the network... Please enter the code you received: 32517 [DEBUG/2020-07-31 16:37:56,136] telethon.extensions.messagepacker: Assigned msg_id = 6855684677401364476 to GetUsersRequest (7f357c5510b8) [DEBUG/2020-07-31 16:37:56,136] telethon.network.mtprotosender: Encrypting 1 message(s) in 32 bytes for sending [DEBUG/2020-07-31 16:37:56,137] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-31 16:37:56,137] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-31 16:37:56,137] telethon.extensions.messagepacker: Assigned msg_id = 6855684677403805884 to MsgsAck (7f357db7a128) [DEBUG/2020-07-31 16:37:56,137] telethon.network.mtprotosender: Encrypting 1 message(s) in 36 bytes for sending [DEBUG/2020-07-31 16:37:56,137] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-31 16:37:56,137] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-31 16:37:56,182] telethon.network.mtprotosender: Handling RPC result for message 6855684677401364476 [DEBUG/2020-07-31 16:37:56,182] telethon.network.mtprotosender: Receiving items from the network... [DEBUG/2020-07-31 16:37:56,182] telethon.extensions.messagepacker: Assigned msg_id = 6855684677584899100 to MsgsAck (7f357c551860) [DEBUG/2020-07-31 16:37:56,182] telethon.network.mtprotosender: Encrypting 1 message(s) in 36 bytes for sending [DEBUG/2020-07-31 16:37:56,182] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-31 16:37:56,182] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-31 16:37:56,182] telethon.extensions.messagepacker: Assigned msg_id = 6855684677586320072 to MsgsAck (7f357c5517f0) [DEBUG/2020-07-31 16:37:56,183] telethon.network.mtprotosender: Encrypting 1 message(s) in 36 bytes for sending [DEBUG/2020-07-31 16:37:56,183] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-31 16:37:56,183] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-31 16:37:56,183] telethon.extensions.messagepacker: Assigned msg_id = 6855684677588468704 to SignInRequest (7f357c551940) [DEBUG/2020-07-31 16:37:56,183] telethon.network.mtprotosender: Encrypting 1 message(s) in 60 bytes for sending [DEBUG/2020-07-31 16:37:56,183] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-31 16:37:56,183] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-31 16:37:56,259] telethon.network.mtprotosender: Handling RPC result for message 6855684677588468704 [DEBUG/2020-07-31 16:37:56,259] telethon.network.mtprotosender: Receiving items from the network... Signed in successfully as S P [DEBUG/2020-07-31 16:37:56,262] telethon.extensions.messagepacker: Assigned msg_id = 6855684677906349332 to SendMessageRequest (7f357c551cc0) [DEBUG/2020-07-31 16:37:56,263] telethon.network.mtprotosender: Encrypting 1 message(s) in 60 bytes for sending [DEBUG/2020-07-31 16:37:56,263] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-31 16:37:56,263] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-31 16:37:56,263] telethon.extensions.messagepacker: Assigned msg_id = 6855684677908515128 to MsgsAck (7f357c5519e8) [DEBUG/2020-07-31 16:37:56,263] telethon.network.mtprotosender: Encrypting 1 message(s) in 36 bytes for sending [DEBUG/2020-07-31 16:37:56,263] telethon.network.mtprotosender: Encrypted messages put in a queue to be sent [DEBUG/2020-07-31 16:37:56,263] telethon.network.mtprotosender: Waiting for messages to send... [DEBUG/2020-07-31 16:37:56,326] telethon.network.mtprotosender: Handling RPC result for message 6855684677906349332 [DEBUG/2020-07-31 16:37:56,327] telethon.network.mtprotosender: Receiving items from the network... [ INFO/2020-07-31 16:37:56,327] telethon.network.mtprotosender: Disconnecting from 149.154.175.58:443/TcpFull... [DEBUG/2020-07-31 16:37:56,327] telethon.network.mtprotosender: Closing current connection... [DEBUG/2020-07-31 16:37:56,328] telethon.network.mtprotosender: Cancelling 0 pending message(s)... [ INFO/2020-07-31 16:37:56,328] telethon.network.mtprotosender: Disconnection from 149.154.175.58:443/TcpFull complete! ```
Lonami commented 4 years ago

There is no switch because you logged in just fine:

Signed in successfully as S P

spencescu commented 4 years ago

Right - logged in just fine with a US telegram account. The login flow on the same server with the Greek account was posted before and it was directed to another data center, which closed the connection soon after.