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

Get PHONE_MIGRATE_5 after sending AuthSendCode #22

Closed
xxxsen opened this issue Oct 11, 2020 · 24 comments · Fixed by #45
Closed

Get PHONE_MIGRATE_5 after sending AuthSendCode #22

xxxsen opened this issue Oct 11, 2020 · 24 comments · Fixed by #45
Labels
bug Something isn't working fixed already this issue is already fixed in latest versions

Comments

@xxxsen
Copy link

xxxsen commented Oct 11, 2020

setCode, err := client.AuthSendCode(&telegram.AuthSendCodeParams{
	"+86xxxx", 0000, "0000000", &telegram.CodeSettings{},
})

run auth example and get error msg like this.

panic: Panicking because of error: sedning AuthSendCode: PHONE_MIGRATE_5 (code 303)
@quenbyako
Copy link
Member

Hey @xxxsen, thanks for question!

This is trouble of telegram api, all clients needs to automatically switch DCs between available. Also, this error is really specific, we don't know how to process it (code of dc is invluded in error id). Btw, we know about this problem since #12 was created. If you have any idea how to process this error code, let me know please.

@quenbyako quenbyako added bug Something isn't working duplicate This issue or pull request already exists labels Oct 11, 2020
@xxxsen
Copy link
Author

xxxsen commented Oct 12, 2020 via email

@quenbyako
Copy link
Member

@xxxsen thanks a lot! I'll research this issue, and answer here until closing it. This article will help

@airani
Copy link

airani commented Oct 24, 2020

@ololosha228 Also, I have this problem. you can fix it? or what can I do for fixing?

@quenbyako
Copy link
Member

quenbyako commented Oct 24, 2020

@airani i have some work in this case, i'll commit part of my solution to this issue in experimental branch and let you know)

In general, there is not so much stuff to do for dealing this error code, you need to say telegram.Client change few session settings: set special ip address and server salt, so i hope, we can fix it in a few days!

@airani
Copy link

airani commented Oct 26, 2020

@ololosha228 you saw this page? https://core.telegram.org/api/datacenter

@quenbyako
Copy link
Member

@airani this branch is leads to fix this issue

@ololosha228 you saw this page?

Yeah, but i still don't understand their point of logic to do stuff like this (cause servers may proxying requests to another, but they are not). Anyway, i working on in, you can help too)

@airani
Copy link

airani commented Oct 27, 2020

I found solution to fix this bug, when you have got this error for a phone number you should change serverHost or DC id to X number in PHONE_MIGRATE_X and again call NewClient with new ClientConfig and note that delete the session file. and try again in a loop until you select the right DC for that phone number.

List of Telegram DC:

ID IP PORT
1 149.154.175.58 443
1 149.154.175.55 443
2 149.154.167.50 443
2 149.154.167.51 443
2 149.154.167.151 443
3 149.154.175.100 443
4 149.154.167.91 443
4 149.154.165.111 443
5 91.108.56.151 443

@codenoid
Copy link

this is major bug, break the whole library

@quenbyako
Copy link
Member

@codenoid it's not a bug, it's a feature)))

Okay, without any jokes, we agree that library must change DC automatically (as many other stuff), i'll prioritize this feature to top level.

Unfortunately, i don't have much time to fix it, maybe someone could collect data about which usual telegram client do automatically without user requests (must dig in tdlib or android clients, they must have automatic jobs like change dc, recreate or repair sessions etc), and i'll just implement it. But i need info about this firstly.

@quenbyako quenbyako removed the duplicate This issue or pull request already exists label Nov 14, 2020
@codenoid
Copy link

codenoid commented Nov 15, 2020

i don't know, but i still able to send code with https://github.com/sdidyk/mtproto

note: but after I input the confirmation code (with sdidyk/mtproto), my telegram account goes banned, i don't know, maybe it's uses old API

@quenbyako
Copy link
Member

@codenoid i'm sorry to hear that 😢

sdidyk/mtproto has bad credentials of app (app id 41994 is banned due to multiple cases spamming and doing malware stuff). Also, few parts of this (xelaj/mtproto) package was reimplemented, but i can say that sdidyk/mtproto doesnt have proper logic of automated things.

@quenbyako
Copy link
Member

wait what? i didn't close it, its only WIP!

@quenbyako quenbyako reopened this Nov 19, 2020
@quenbyako
Copy link
Member

quenbyako commented Nov 19, 2020

@xxxsen @airani @codenoid and also @patrikhermansson, i have some news!

So i had a few time to fix it, but it's looks so messy as i think. This commit will help. I hope.

@codenoid @xxxsen due to this error affects to specific phone numbers, can you please test this fix, and give us report?

@quenbyako quenbyako added help wanted Extra attention is needed need investigation Further information is requested labels Nov 19, 2020
@patrikhermansson
Copy link

Can confirm that it works well in my testing! Thanks for fixing and sorry for late reply.

@quenbyako
Copy link
Member

@patrikhermansson check out also this branch

We had reworked literally all package include new tl parser, which doesn't panic every second, also we reimplemented codegen tool, now personally me don't cry when i'm scrolling telegram package in godoc))))

@quenbyako quenbyako linked a pull request Nov 28, 2020 that will close this issue
@patrikhermansson
Copy link

Hi! Sorry about this but clearly didn't test enough earlier. It doesn't work yet I'm afraid. Have not solved it but a few issues I found:

  1. tryToProcessErr() in mtproto.go doesn't match with the PHONE_MIGRATE error. The switch statement matches against "PHONE_MIGRATE_X" but the e.Message is "PHONE_MIGRATE_4" (and assumign _1, _2, _3 etc.). This is an easy fix with somethign like if strings.Contains(e.Message, "PHONE_MIGRATE_") {} instead.

  2. e.AdditionalInfo does not contain DC id, it's nil which means newIP, found := m.dclist[e.AdditionalInfo.(int)] panics. Might be that we have to parse the e.Message and get the DC id from there instead.

  3. However, even changing these things, it doesn't work. I get the following error:

[]uint8{ 0x00, 0x00, 0x00, 0x00, } &errors.errorString{ s: "context canceled", }

Apologies again for being mistaken in the previous message.

@quenbyako
Copy link
Member

@patrikhermansson errors with additional data (like EMAIL_UNCONFIRMED_X PASSWORD_TOO_FRESH_X etc.) extracting data from simple text and giving you extended struct with custom data and native error name (you can research TryExpandError implementation)

But i'm worried, that you didn't solve this issue, could you please post here github gist with testing code? Maybe we need to add more docs of how to solve errors with additional data...

@patrikhermansson
Copy link

Ok had a look. Yeah you're right, there's an issue in TryExpandError on line 77. It should be if choosedPrefixSuffix == nil not if choosedPrefixSuffix != nil.

But even if I fix this (which sorts point 1 and 2 in my previous comment). I still get the error:

[]uint8{ 0x00, 0x00, 0x00, 0x00, } &errors.errorString{ s: "context canceled", }

So this is separate. Gonna see if i can sort example code

@patrikhermansson
Copy link

TryExpandError error is fixed in new_decoder_refactoring branch so not gonna do a pull request but will try to figure out the context issue. Clearly one that gets cancelled somewhere

@quenbyako quenbyako added fixed already this issue is already fixed in latest versions and removed help wanted Extra attention is needed need investigation Further information is requested labels Dec 23, 2020
@quenbyako
Copy link
Member

Due to multiple responses, this bug was fixed in release candidate branch, so i'll close it

@VityaSchel
Copy link

о боже ничего не работает об оже

@Mookiees
Copy link

Mookiees commented Sep 6, 2022

эээ чо PHONE_MIGRATE_2

@VityaSchel
Copy link

эээ чо PHONE_MIGRATE_2

а ничо нормально общайся

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed already this issue is already fixed in latest versions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants