Git Product home page Git Product logo

Comments (30)

cjongseok avatar cjongseok commented on June 3, 2024 3

@vannnnish I think it should be 149.154.167.50:443 , not 149.154.167.5:443.
And please do not upload your api_id/hash and phone number.

from mtproto.

Reid-Garner avatar Reid-Garner commented on June 3, 2024 1

This magically started working for me - no code changes. Gotta love that :(

On a different note, I added functionality to support 2fa via password to the Conn. Once i clean it up a bit, i will send it your way.

from mtproto.

innovative-sol avatar innovative-sol commented on June 3, 2024 1

Thanks a lot for the fast replies and... congratulations! I can confirm that IT WORKS, I managed to successfully authenticate on a new session! πŸ‘ πŸ₯‡

from mtproto.

cjongseok avatar cjongseok commented on June 3, 2024

Are you in China? If so, please make sure the server endpoint (149.154.167.50:443) is reachable from your PC. You can test it using Telenet on Windows and Netcat on Mac/Linux.

from mtproto.

vannnnish avatar vannnnish commented on June 3, 2024

Hello. I am in China .
It is success when I ping to 149.154.167.50 .

I am using VPN.

from mtproto.

cjongseok avatar cjongseok commented on June 3, 2024

@vannnnish ping does not make sure you can reach to the port. It just shows whether the ip is reachable. If you are using Linux/Mac, can you try "nc -vz 149.154.167.50 443"? Please share its result together with your mtproto log as @heroto did.

from mtproto.

vannnnish avatar vannnnish commented on June 3, 2024

@cjongseok Ok,
log:

2018/05/05 18:58:39 [MM 3718131] start
2018/05/05 18:58:39 [MM 3718131] loadsession of  +86******
2018/05/05 18:58:39 [0-945840640502653585] dial TCP to 149.154.167.99:443
2018/05/05 18:58:39 [0-945840640502653585] read: start
2018/05/05 18:58:39 [0-945840640502653585] send: start
2018/05/05 18:58:39 [0-945840640502653585] send *mtproto.ReqInvokeWithLayer: {"Layer":71,"Query":{"type_url":"type.googleapis.com/mtproto.ReqInitConnection","value":"*************************"}}
2018/05/05 18:58:40 [0-945840640502653585] read: type: <nil>, data: <nil>, err: EOF
2018/05/05 18:58:40 [0-945840640502653585] read: lost connection (captured EOF). reconnect to 149.154.167.99:443
2018/05/05 18:58:40 [0-945840640502653585] notify Event, mtproto.refreshSession: {}, to [0xc4200be120]
2018/05/05 18:58:40 [MM 3718131] refreshSession  945840640502653585
2018/05/05 18:58:41 [MM 3718131] spinlocked. Session(945840640502653585) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/05/05 18:58:42 [MM 3718131] spinlocked. Session(945840640502653585) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/05/05 18:58:43 [MM 3718131] spinlocked. Session(945840640502653585) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/05/05 18:58:44 [MM 3718131] spinlocked. Session(945840640502653585) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/05/05 18:58:45 [MM 3718131] spinlocked. Session(945840640502653585) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/05/05 18:58:46 [MM 3718131] spinlocked. Session(945840640502653585) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/05/05 18:58:47 [MM 3718131] spinlocked. Session(945840640502653585) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/05/05 18:58:48 [MM 3718131] spinlocked. Session(945840640502653585) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/05/05 18:58:49 [MM 3718131] spinlocked. Session(945840640502653585) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/05/05 18:58:49 [MM 3718131] connect failure: Handshaking Failure: TL_invokeWithLayer Timeout(10.000000 s)
2018/05/05 18:58:49 [0-945840640502653585] send <nil>: null
2018/05/05 18:58:49 [0-945840640502653585] send <nil>: null
2018/05/05 18:58:49 [0-945840640502653585] send <nil>: null
2018/05/05 18:58:49 [0-945840640502653585] send: stop
2018/05/05 18:58:49 [0-945840640502653585] read: wait for inner routine ...
2018/05/05 18:58:49 [0-945840640502653585] read: stop
2018/05/05 18:58:49 [0-945840640502653585] notify Event, mtproto.SessionDiscarded: {}, to [0xc4200be120]
panic: Handshaking Failure: TL_invokeWithLayer Timeout(10.000000 s)


nc result:

found 0 associations
found 1 connections:
     1: flags=82<CONNECTED,PREFERRED>
        outif utun1
        src 172.21.0.1 port 59557
        dst 149.154.167.50 port 443
        rank info not available
        TCP aux info available

Connection to 149.154.167.50 port 443 [tcp/https] succeeded!

thanks.

from mtproto.

cjongseok avatar cjongseok commented on June 3, 2024

@vannnnish can you check your api_id, api_hash, and, server address are valid in https://my.telegram.org/apps ? And you tried mtproto/examples/simpleshell?

from mtproto.

vannnnish avatar vannnnish commented on June 3, 2024

I sign in success use method without key. so I think those api_id ,api_hash ,server address are fine...

from mtproto.

cjongseok avatar cjongseok commented on June 3, 2024

@vannnnish ok, then the error is from mtproto/examples/simpleshell, when you run it with key?

from mtproto.

vannnnish avatar vannnnish commented on June 3, 2024
2018/05/05 19:31:14 MAIN: new authentication
2018/05/05 19:31:14 [MM 243010863] start
2018/05/05 19:31:14 [MM 243010863] newsession to  149.154.167.50:443
2018/05/05 19:31:14 [0-7908473676283906779] dial TCP to 149.154.167.50:443
2018/05/05 19:31:17 [0-7908473676283906779] send: start
2018/05/05 19:31:17 [0-7908473676283906779] read: start
2018/05/05 19:31:17 [0-7908473676283906779] send *mtproto.ReqInvokeWithLayer: {"Layer":71,"Query":{"type_url":"type.googleapis.com/mtproto.ReqInitConnection","value":"CJySDRIHVW5rbm93bhoMZGFyd2luL2FtZDY0IgUwLjAuMSoCZW46AmVuQi4KLHR5cGUuZ29vZ2xlYXBpcy5jb20vbXRwcm90by5SZXFIZWxwR2V0Q29uZmln"}}
2018/05/05 19:31:17 [0-7908473676283906779] read: type: mtproto.TL_msg_container, data: {[{6552057982236821505 1 28 {6552057981229329584 5807292957917702167 [73 210 102 15 103 114 239 144]}} {6552057982236974081 2 20 {[6552057981229329584]}}]}, err: <nil>
2018/05/05 19:31:17 [0-7908473676283906779] send mtproto.TL_msgs_ack: {}
2018/05/05 19:31:17 [0-7908473676283906779] read: type: mtproto.TL_rpc_result, data: {6552057981229329584 Date:1525519877 Expires:1525523106 TestMode:<BoolFalse:<> > ThisDc:2 DcOptions:<Value:<Id:1 IpAddress:"149.154.175.50" Port:443 > > DcOptions:<Value:<Flags:1 Id:1 IpAddress:"2001:0b28:f23d:f001:0000:0000:0000:000a" Port:443 > > DcOptions:<Value:<Id:2 IpAddress:"149.154.167.50" Port:443 > > DcOptions:<Value:<Flags:16 Id:2 IpAddress:"149.154.167.51" Port:443 > > DcOptions:<Value:<Flags:1 Id:2 IpAddress:"2001:067c:04e8:f002:0000:0000:0000:000a" Port:443 > > DcOptions:<Value:<Id:3 IpAddress:"149.154.175.100" Port:443 > > DcOptions:<Value:<Flags:1 Id:3 IpAddress:"2001:0b28:f23d:f003:0000:0000:0000:000a" Port:443 > > DcOptions:<Value:<Id:4 IpAddress:"149.154.167.92" Port:443 > > DcOptions:<Value:<Flags:1 Id:4 IpAddress:"2001:067c:04e8:f004:0000:0000:0000:000a" Port:443 > > DcOptions:<Value:<Flags:2 Id:4 IpAddress:"149.154.165.120" Port:443 > > DcOptions:<Value:<Id:5 IpAddress:"91.108.56.125" Port:443 > > DcOptions:<Value:<Flags:1 Id:5 IpAddress:"2001:0b28:f23f:f005:0000:0000:0000:000a" Port:443 > > ChatSizeMax:200 MegagroupSizeMax:100000 ForwardedCountMax:100 OnlineUpdatePeriodMs:120000 OfflineBlurTimeoutMs:5000 OfflineIdleTimeoutMs:30000 OnlineCloudTimeoutMs:300000 NotifyCloudDelayMs:30000 NotifyDefaultDelayMs:1500 ChatBigSize:10 PushChatPeriodMs:60000 PushChatLimit:2 SavedGifsLimit:200 EditTimeLimit:172800 RatingEDecay:2419200 StickersRecentLimit:30 StickersFavedLimit:5 PinnedDialogsCountMax:5 CallReceiveTimeoutMs:20000 CallRingTimeoutMs:90000 CallConnectTimeoutMs:30000 CallPacketTimeoutMs:10000 MeUrlPrefix:"https://t.me/" }, err: <nil>
2018/05/05 19:31:17 [0-7908473676283906779] process: unknown data type *mtproto.PredConfig {{"Date":1525519877,"Expires":1525523106,"TestMode":{"Value":{"BoolFalse":{}}},"ThisDc":2,"DcOptions":[{"Value":{"Id":1,"IpAddress":"149.154.175.50","Port":443}},{"Value":{"Flags":1,"Id":1,"IpAddress":"2001:0b28:f23d:f001:0000:0000:0000:000a","Port":443}},{"Value":{"Id":2,"IpAddress":"149.154.167.50","Port":443}},{"Value":{"Flags":16,"Id":2,"IpAddress":"149.154.167.51","Port":443}},{"Value":{"Flags":1,"Id":2,"IpAddress":"2001:067c:04e8:f002:0000:0000:0000:000a","Port":443}},{"Value":{"Id":3,"IpAddress":"149.154.175.100","Port":443}},{"Value":{"Flags":1,"Id":3,"IpAddress":"2001:0b28:f23d:f003:0000:0000:0000:000a","Port":443}},{"Value":{"Id":4,"IpAddress":"149.154.167.92","Port":443}},{"Value":{"Flags":1,"Id":4,"IpAddress":"2001:067c:04e8:f004:0000:0000:0000:000a","Port":443}},{"Value":{"Flags":2,"Id":4,"IpAddress":"149.154.165.120","Port":443}},{"Value":{"Id":5,"IpAddress":"91.108.56.125","Port":443}},{"Value":{"Flags":1,"Id":5,"IpAddress":"2001:0b28:f23f:f005:0000:0000:0000:000a","Port":443}}],"ChatSizeMax":200,"MegagroupSizeMax":100000,"ForwardedCountMax":100,"OnlineUpdatePeriodMs":120000,"OfflineBlurTimeoutMs":5000,"OfflineIdleTimeoutMs":30000,"OnlineCloudTimeoutMs":300000,"NotifyCloudDelayMs":30000,"NotifyDefaultDelayMs":1500,"ChatBigSize":10,"PushChatPeriodMs":60000,"PushChatLimit":2,"SavedGifsLimit":200,"EditTimeLimit":172800,"RatingEDecay":2419200,"StickersRecentLimit":30,"StickersFavedLimit":5,"PinnedDialogsCountMax":5,"CallReceiveTimeoutMs":20000,"CallRingTimeoutMs":90000,"CallConnectTimeoutMs":30000,"CallPacketTimeoutMs":10000,"MeUrlPrefix":"https://t.me/"}}
2018/05/05 19:31:17 [0-7908473676283906779] config: {"Date":1525519877,"Expires":1525523106,"TestMode":{"Value":{"BoolFalse":{}}},"ThisDc":2,"DcOptions":[{"Value":{"Id":1,"IpAddress":"149.154.175.50","Port":443}},{"Value":{"Flags":1,"Id":1,"IpAddress":"2001:0b28:f23d:f001:0000:0000:0000:000a","Port":443}},{"Value":{"Id":2,"IpAddress":"149.154.167.50","Port":443}},{"Value":{"Flags":16,"Id":2,"IpAddress":"149.154.167.51","Port":443}},{"Value":{"Flags":1,"Id":2,"IpAddress":"2001:067c:04e8:f002:0000:0000:0000:000a","Port":443}},{"Value":{"Id":3,"IpAddress":"149.154.175.100","Port":443}},{"Value":{"Flags":1,"Id":3,"IpAddress":"2001:0b28:f23d:f003:0000:0000:0000:000a","Port":443}},{"Value":{"Id":4,"IpAddress":"149.154.167.92","Port":443}},{"Value":{"Flags":1,"Id":4,"IpAddress":"2001:067c:04e8:f004:0000:0000:0000:000a","Port":443}},{"Value":{"Flags":2,"Id":4,"IpAddress":"149.154.165.120","Port":443}},{"Value":{"Id":5,"IpAddress":"91.108.56.125","Port":443}},{"Value":{"Flags":1,"Id":5,"IpAddress":"2001:0b28:f23f:f005:0000:0000:0000:000a","Port":443}}],"ChatSizeMax":200,"MegagroupSizeMax":100000,"ForwardedCountMax":100,"OnlineUpdatePeriodMs":120000,"OfflineBlurTimeoutMs":5000,"OfflineIdleTimeoutMs":30000,"OnlineCloudTimeoutMs":300000,"NotifyCloudDelayMs":30000,"NotifyDefaultDelayMs":1500,"ChatBigSize":10,"PushChatPeriodMs":60000,"PushChatLimit":2,"SavedGifsLimit":200,"EditTimeLimit":172800,"RatingEDecay":2419200,"StickersRecentLimit":30,"StickersFavedLimit":5,"PinnedDialogsCountMax":5,"CallReceiveTimeoutMs":20000,"CallRingTimeoutMs":90000,"CallConnectTimeoutMs":30000,"CallPacketTimeoutMs":10000,"MeUrlPrefix":"https://t.me/"}
2018/05/05 19:31:17 [0-7908473676283906779] notify Event, mtproto.SessionEstablished: {}, to [0xc4200ba120]
2018/05/05 19:31:17 [0-7908473676283906779] ping: start
2018/05/05 19:31:17 [MM 243010863] session established 7908473676283906779
2018/05/05 19:31:17 [mconn 446369967] start
2018/05/05 19:31:17 [mconn 446369967] opened.
2018/05/05 19:31:17 [mconn 446369967] wait for a session binding ...
2018/05/05 19:31:17 [MM 243010863] connectionOpened  446369967
2018/05/05 19:31:17 [mconn 446369967] bind: mconn.discardedUpdatesState is nil
2018/05/05 19:31:17 [MM 243010863] sessionBound: session 7908473676283906779 is bound to mconn 446369967
2018/05/05 19:31:17 [mconn 446369967] bound to session 7908473676283906779
2018/05/05 19:31:17 [446369967-7908473676283906779] send mtproto.TL_msgs_ack: {}
2018/05/05 19:31:18 [446369967-7908473676283906779] send *mtproto.ReqAuthSendCode: {"Flags":1,"PhoneNumber":"+8617318070950","CurrentNumber":{"Value":{"BoolTrue":{}}},"ApiId":215324,"ApiHash":"c653edbd702c7883725fd6f45c0dc65d"}
2018/05/05 19:31:18 [446369967-7908473676283906779] read: type: mtproto.TL_rpc_result, data: {6552057986033939032 mtproto RPC error: 303 PHONE_MIGRATE_5}, err: <nil>
2018/05/05 19:31:18 [446369967-7908473676283906779] send mtproto.TL_msgs_ack: {}
2018/05/05 19:31:18 [MM 243010863] renewSession to  91.108.56.125:443
2018/05/05 19:31:18 [446369967-7908473676283906779] notify Event, mtproto.discardSession: {}, to [0xc4200ba120 0xc42029e0c0]
2018/05/05 19:31:18 [mconn 446369967] session will be discarded7908473676283906779
2018/05/05 19:31:18 [MM 243010863] discard session  7908473676283906779
2018/05/05 19:31:18 [mconn 446369967] unbound to session 7908473676283906779
2018/05/05 19:31:18 [MM 243010863] sessionUnbound: session 7908473676283906779 is unbound from mconn 446369967
2018/05/05 19:31:19 [446369967-7908473676283906779] send: stop
2018/05/05 19:31:19 [446369967-7908473676283906779] read: type: <nil>, data: <nil>, err: read tcp 172.21.0.1:51034->149.154.167.50:443: use of closed network connection
2018/05/05 19:31:19 [446369967-7908473676283906779] read: TCP connection closed (read tcp 172.21.0.1:51034->149.154.167.50:443: use of closed network connection)
2018/05/05 19:31:19 [446369967-7908473676283906779] read: wait for inner routine ...
2018/05/05 19:31:19 [446369967-7908473676283906779] read: stop
2018/05/05 19:31:19 [446369967-7908473676283906779] notify Event, mtproto.SessionDiscarded: {}, to [0xc4200ba120 0xc42029e0c0]
2018/05/05 19:31:19 [MM 243010863] session is discarded. keep its updates state, (json): {}
2018/05/05 19:31:19 [MM 243010863] renewRoutine: req newsession
2018/05/05 19:31:19 [MM 243010863] session discarded  7908473676283906779
2018/05/05 19:31:19 [MM 243010863] newsession to  91.108.56.125:443
2018/05/05 19:31:19 [0-6157452944715194879] dial TCP to 91.108.56.125:443
2018/05/05 19:31:20 [0-6157452944715194879] send: start
2018/05/05 19:31:20 [0-6157452944715194879] send *mtproto.ReqInvokeWithLayer: {"Layer":71,"Query":{"type_url":"type.googleapis.com/mtproto.ReqInitConnection","value":"CJySDRIHVW5rbm93bhoMZGFyd2luL2FtZDY0IgUwLjAuMSoCZW46AmVuQi4KLHR5cGUuZ29vZ2xlYXBpcy5jb20vbXRwcm90by5SZXFIZWxwR2V0Q29uZmln"}}
2018/05/05 19:31:20 [0-6157452944715194879] read: start
2018/05/05 19:31:20 [0-6157452944715194879] read: type: mtproto.TL_msg_container, data: {[{6552057996693540865 1 28 {6552057994607661740 3103308697958403107 [243 196 33 19 126 28 169 95]}} {6552057996693583873 2 20 {[6552057994607661740]}}]}, err: <nil>
2018/05/05 19:31:20 [0-6157452944715194879] send mtproto.TL_msgs_ack: {}
2018/05/05 19:31:20 [0-6157452944715194879] read: type: mtproto.TL_rpc_result, data: {6552057994607661740 Date:1525519880 Expires:1525523892 TestMode:<BoolFalse:<> > ThisDc:5 DcOptions:<Value:<Id:1 IpAddress:"149.154.175.50" Port:443 > > DcOptions:<Value:<Flags:1 Id:1 IpAddress:"2001:0b28:f23d:f001:0000:0000:0000:000a" Port:443 > > DcOptions:<Value:<Id:2 IpAddress:"149.154.167.50" Port:443 > > DcOptions:<Value:<Flags:16 Id:2 IpAddress:"149.154.167.51" Port:443 > > DcOptions:<Value:<Flags:1 Id:2 IpAddress:"2001:067c:04e8:f002:0000:0000:0000:000a" Port:443 > > DcOptions:<Value:<Id:3 IpAddress:"149.154.175.100" Port:443 > > DcOptions:<Value:<Flags:1 Id:3 IpAddress:"2001:0b28:f23d:f003:0000:0000:0000:000a" Port:443 > > DcOptions:<Value:<Id:4 IpAddress:"149.154.167.92" Port:443 > > DcOptions:<Value:<Flags:1 Id:4 IpAddress:"2001:067c:04e8:f004:0000:0000:0000:000a" Port:443 > > DcOptions:<Value:<Flags:2 Id:4 IpAddress:"149.154.165.120" Port:443 > > DcOptions:<Value:<Id:5 IpAddress:"91.108.56.125" Port:443 > > DcOptions:<Value:<Flags:1 Id:5 IpAddress:"2001:0b28:f23f:f005:0000:0000:0000:000a" Port:443 > > ChatSizeMax:200 MegagroupSizeMax:100000 ForwardedCountMax:100 OnlineUpdatePeriodMs:120000 OfflineBlurTimeoutMs:5000 OfflineIdleTimeoutMs:30000 OnlineCloudTimeoutMs:300000 NotifyCloudDelayMs:30000 NotifyDefaultDelayMs:1500 ChatBigSize:10 PushChatPeriodMs:60000 PushChatLimit:2 SavedGifsLimit:200 EditTimeLimit:172800 RatingEDecay:2419200 StickersRecentLimit:30 StickersFavedLimit:5 PinnedDialogsCountMax:5 CallReceiveTimeoutMs:20000 CallRingTimeoutMs:90000 CallConnectTimeoutMs:30000 CallPacketTimeoutMs:10000 MeUrlPrefix:"https://t.me/" }, err: <nil>
2018/05/05 19:31:20 [0-6157452944715194879] process: unknown data type *mtproto.PredConfig {{"Date":1525519880,"Expires":1525523892,"TestMode":{"Value":{"BoolFalse":{}}},"ThisDc":5,"DcOptions":[{"Value":{"Id":1,"IpAddress":"149.154.175.50","Port":443}},{"Value":{"Flags":1,"Id":1,"IpAddress":"2001:0b28:f23d:f001:0000:0000:0000:000a","Port":443}},{"Value":{"Id":2,"IpAddress":"149.154.167.50","Port":443}},{"Value":{"Flags":16,"Id":2,"IpAddress":"149.154.167.51","Port":443}},{"Value":{"Flags":1,"Id":2,"IpAddress":"2001:067c:04e8:f002:0000:0000:0000:000a","Port":443}},{"Value":{"Id":3,"IpAddress":"149.154.175.100","Port":443}},{"Value":{"Flags":1,"Id":3,"IpAddress":"2001:0b28:f23d:f003:0000:0000:0000:000a","Port":443}},{"Value":{"Id":4,"IpAddress":"149.154.167.92","Port":443}},{"Value":{"Flags":1,"Id":4,"IpAddress":"2001:067c:04e8:f004:0000:0000:0000:000a","Port":443}},{"Value":{"Flags":2,"Id":4,"IpAddress":"149.154.165.120","Port":443}},{"Value":{"Id":5,"IpAddress":"91.108.56.125","Port":443}},{"Value":{"Flags":1,"Id":5,"IpAddress":"2001:0b28:f23f:f005:0000:0000:0000:000a","Port":443}}],"ChatSizeMax":200,"MegagroupSizeMax":100000,"ForwardedCountMax":100,"OnlineUpdatePeriodMs":120000,"OfflineBlurTimeoutMs":5000,"OfflineIdleTimeoutMs":30000,"OnlineCloudTimeoutMs":300000,"NotifyCloudDelayMs":30000,"NotifyDefaultDelayMs":1500,"ChatBigSize":10,"PushChatPeriodMs":60000,"PushChatLimit":2,"SavedGifsLimit":200,"EditTimeLimit":172800,"RatingEDecay":2419200,"StickersRecentLimit":30,"StickersFavedLimit":5,"PinnedDialogsCountMax":5,"CallReceiveTimeoutMs":20000,"CallRingTimeoutMs":90000,"CallConnectTimeoutMs":30000,"CallPacketTimeoutMs":10000,"MeUrlPrefix":"https://t.me/"}}
2018/05/05 19:31:20 [0-6157452944715194879] config: {"Date":1525519880,"Expires":1525523892,"TestMode":{"Value":{"BoolFalse":{}}},"ThisDc":5,"DcOptions":[{"Value":{"Id":1,"IpAddress":"149.154.175.50","Port":443}},{"Value":{"Flags":1,"Id":1,"IpAddress":"2001:0b28:f23d:f001:0000:0000:0000:000a","Port":443}},{"Value":{"Id":2,"IpAddress":"149.154.167.50","Port":443}},{"Value":{"Flags":16,"Id":2,"IpAddress":"149.154.167.51","Port":443}},{"Value":{"Flags":1,"Id":2,"IpAddress":"2001:067c:04e8:f002:0000:0000:0000:000a","Port":443}},{"Value":{"Id":3,"IpAddress":"149.154.175.100","Port":443}},{"Value":{"Flags":1,"Id":3,"IpAddress":"2001:0b28:f23d:f003:0000:0000:0000:000a","Port":443}},{"Value":{"Id":4,"IpAddress":"149.154.167.92","Port":443}},{"Value":{"Flags":1,"Id":4,"IpAddress":"2001:067c:04e8:f004:0000:0000:0000:000a","Port":443}},{"Value":{"Flags":2,"Id":4,"IpAddress":"149.154.165.120","Port":443}},{"Value":{"Id":5,"IpAddress":"91.108.56.125","Port":443}},{"Value":{"Flags":1,"Id":5,"IpAddress":"2001:0b28:f23f:f005:0000:0000:0000:000a","Port":443}}],"ChatSizeMax":200,"MegagroupSizeMax":100000,"ForwardedCountMax":100,"OnlineUpdatePeriodMs":120000,"OfflineBlurTimeoutMs":5000,"OfflineIdleTimeoutMs":30000,"OnlineCloudTimeoutMs":300000,"NotifyCloudDelayMs":30000,"NotifyDefaultDelayMs":1500,"ChatBigSize":10,"PushChatPeriodMs":60000,"PushChatLimit":2,"SavedGifsLimit":200,"EditTimeLimit":172800,"RatingEDecay":2419200,"StickersRecentLimit":30,"StickersFavedLimit":5,"PinnedDialogsCountMax":5,"CallReceiveTimeoutMs":20000,"CallRingTimeoutMs":90000,"CallConnectTimeoutMs":30000,"CallPacketTimeoutMs":10000,"MeUrlPrefix":"https://t.me/"}
2018/05/05 19:31:20 [0-6157452944715194879] notify Event, mtproto.SessionEstablished: {}, to [0xc4200ba120]
2018/05/05 19:31:20 [0-6157452944715194879] ping: start
2018/05/05 19:31:20 [MM 243010863] session established 6157452944715194879
2018/05/05 19:31:20 [MM 243010863] sessionBound: session 6157452944715194879 is bound to mconn 446369967
2018/05/05 19:31:20 [MM 243010863] renewSession done
2018/05/05 19:31:20 [mconn 446369967] bound to session 6157452944715194879
2018/05/05 19:31:21 [446369967-6157452944715194879] send mtproto.TL_msgs_ack: {}
2018/05/05 19:31:21 [446369967-6157452944715194879] send *mtproto.ReqAuthSendCode: {"Flags":1,"PhoneNumber":"+8617318070950","CurrentNumber":{"Value":{"BoolTrue":{}}},"ApiId":215324,"ApiHash":"c653edbd702c7883725fd6f45c0dc65d"}
2018/05/05 19:31:22 [446369967-6157452944715194879] read: type: mtproto.TL_rpc_result, data: {6552058002711034784 mtproto RPC error: 420 FLOOD_WAIT_72962}, err: <nil>
2018/05/05 19:31:22 mtproto RPC error: 420 FLOOD_WAIT_72962

I find I cant sign in now.

from mtproto.

cjongseok avatar cjongseok commented on June 3, 2024

@vannnnish Oh, for many sendCode tries your phone is banned for 72962 seconds, which 420 FLOOD_WAIT_72962 means. According to your log, it seems InvokeWithLayer you failed before works now. Can you let me know what made the difference?

I have just tried mtproto/examples/simpleshell on an Ubuntu container, and it succeeded.

# On my laptop
docker run -it ubuntu /bin/bash

# On the container
apt-get update && apt-get install -y git golang-go
mkdir /root/ws
export GOPATH=/root/ws
go get -u github.com/cjongseok/mtproto
go run $GOPATH/src/github.com/cjongseok/mtproto/examples/simpleshell/main.go <MY_API_ID> <MY_API_HASH> <MY_PHONE> <ADDR>
# Succeeded to create a key

go run $GOPATH/src/github.com/cjongseok/mtproto/examples/simpleshell/main.go <MY_API_ID> <MY_API_HASH> <MY_PHONE> <ADDR> key.mtproto
# Succeeded to log in

And please be careful of your credentials.

from mtproto.

vannnnish avatar vannnnish commented on June 3, 2024

I am sorry. It busy since last talk. I was try on docker. I succeeded to log in without key generate. Neither log file.

then I enter the sample dir. and run : go run main.go ***** ************** +86******** 149.154.167.5:443
there are ss.log and key.tmproto.
but when I added key in the tail of command . I got wrong.

2018/05/07 07:43:21 [0-2172116456372458429] read: start
2018/05/07 07:43:21 [0-2172116456372458429] send *mtproto.ReqInvokeWithLayer: {"Layer":71,"Query":{"type_url":"type.googleapis.com/mtproto.ReqInitConnection","value":"CKiSERIHVW5rbm93bhoLbGludXgvYW1kNjQiBTAuMC4xKgJlbjoCZW5CLgosdHlwZS5nb29nbGVhcGlzLmNvbS9tdHByb3RvLlJlcUhlbHBHZXRDb25maWc="}}
2018/05/07 07:43:31 [MM 1536450645] connect failure: Handshaking Failure: TL_invokeWithLayer Timeout(10.000000 s)
2018/05/07 07:43:31 [0-2172116456372458429] send: stop
2018/05/07 07:43:31 [0-2172116456372458429] read: wait for inner routine ...
2018/05/07 07:43:31 [0-2172116456372458429] read: type: <nil>, data: <nil>, err: read tcp 172.17.0.2:47106->149.154.167.5:443: use of closed network connection
2018/05/07 07:43:31 [0-2172116456372458429] read: TCP connection closed (read tcp 172.17.0.2:47106->149.154.167.5:443: use of closed network connection)
2018/05/07 07:43:31 [0-2172116456372458429] read: stop
2018/05/07 07:43:31 [0-2172116456372458429] notify Event, mtproto.SessionDiscarded: {}, to [0xc82000a420]
2018/05/07 07:43:31 Handshaking Failure: TL_invokeWithLayer Timeout(10.000000 s)

from mtproto.

Reid-Garner avatar Reid-Garner commented on June 3, 2024

@cjongseok I am having this issue as well, when connecting using a preexisting key file/session. A new login works great.

My output is slightly different, and claiming a -404 ( guessing a 404?)

> 2018/05/13 11:52:12 [0-6864795462405635934] read: type: <nil>, data: <nil>, err: Server response error: -404
> 2018/05/13 11:52:12 [0-6864795462405635934] read: unknown error, Server response error: -404. reconnect to 149.154.167.50:443
> 2018/05/13 11:52:12 [0-6864795462405635934] notify Event, mtproto.refreshSession: {}, to [0xc0420461e0]
> 2018/05/13 11:52:12 [MM 1598334746] refreshSession  6864795462405635934
> 2018/05/13 11:52:13 [MM 1598334746] spinlocked. Session(6864795462405635934) is waiting for a response from either invokeWithLayer or updatesGetState.
> 2018/05/13 11:52:14 [MM 1598334746] spinlocked. Session(6864795462405635934) is waiting for a response from either invokeWithLayer or updatesGetState.
> 2018/05/13 11:52:15 [MM 1598334746] spinlocked. Session(6864795462405635934) is waiting for a response from either invokeWithLayer or updatesGetState.
> 2018/05/13 11:52:16 [MM 1598334746] spinlocked. Session(6864795462405635934) is waiting for a response from either invokeWithLayer or updatesGetState.
> 2018/05/13 11:52:17 [MM 1598334746] spinlocked. Session(6864795462405635934) is waiting for a response from either invokeWithLayer or updatesGetState.
> 2018/05/13 11:52:18 [MM 1598334746] spinlocked. Session(6864795462405635934) is waiting for a response from either invokeWithLayer or updatesGetState.
> 2018/05/13 11:52:19 [MM 1598334746] spinlocked. Session(6864795462405635934) is waiting for a response from either invokeWithLayer or updatesGetState.
> 2018/05/13 11:52:20 [MM 1598334746] spinlocked. Session(6864795462405635934) is waiting for a response from either invokeWithLayer or updatesGetState.
> 2018/05/13 11:52:21 [MM 1598334746] spinlocked. Session(6864795462405635934) is waiting for a response from either invokeWithLayer or updatesGetState.
> 2018/05/13 11:52:22 [MM 1598334746] connect failure: Handshaking Failure: TL_invokeWithLayer Timeout(10.000000 s)
> 2018/05/13 11:52:22 [0-6864795462405635934] send: stop
> 2018/05/13 11:52:22 [0-6864795462405635934] read: wait for inner routine ...
> 2018/05/13 11:52:22 [0-6864795462405635934] read: stop
> 2018/05/13 11:52:22 [0-6864795462405635934] notify Event, mtproto.SessionDiscarded: {}, to [0xc0420461e0]
> Handshaking Failure: TL_invokeWithLayer Timeout(10.000000 s)

If you have any insight, it would be greatly appreciated.

from mtproto.

cjongseok avatar cjongseok commented on June 3, 2024

@Reid-Garner thanks for your interest in my code. Finally I found the culprit. In the middle of the log, you can find another server endpoint by the keyword 'newsession to'. In my case, it is 91.108.56.133:443. Please sign-in to this server with your key file.

from mtproto.

Reid-Garner avatar Reid-Garner commented on June 3, 2024

Unfortunately that is not the same issue that I am having. I do have a new session to, but it is the same ip.

One thing I am noticing is that the key.mtproto file is not touched again after the initial phone number entry. It is not updated after entering the key from telegram to allow access. Also in the log, the send *mtproto.ReqInvokeWithLayer always has the same value.

I am wondering if this is why it returns a 404. I have also used the older code which has a keygen tool which does update the key file after successful login, but that too does not work.

I havent spent too much time debugging it yet though, and if i figure it out, will post a pull request.

from mtproto.

cjongseok avatar cjongseok commented on June 3, 2024

@Reid-Garner Regarding the code 404, I think I need to let you know 'PHONE_MIGRATE_N' on the initial sign-in without key. In the procedure, mtproto tries its authentication to the the specified server. However, usually the server is not responsible for the authentication on the given phone number, and rejects the authentication with a message 'PHONE_MIGRATE_N'. It means that try the authentication again to the 'N'th server in the server list you received on ReqInvokeWithLayer; the values in ReqInvokeWithLayer are always same and it fetches server list by sending 'ReqHelpGetConfig' as its query. mtproto, then, establishes a new session to the new server endpoint(it is why I commented that you can find out new server endpoint with the keyword 'newsession to'), proceeds the authentication, and stores the new server endpoint in the key file.

I believed the code 404 would mean that this server is wrong and you need to use the migrated server you used in the authentication. So I made the above commit enforcing to use server endpoint in the key file after the initial sign-in.

In your case, however, it seems the specified server(149.154.167.50:443) is also responsible for your authentication. If you find something out and send a pull request, it would be great. Thank you :)

from mtproto.

cjongseok avatar cjongseok commented on June 3, 2024

@Reid-Garner Great! 2fa would be awesome. I will look forward to your signal :)

from mtproto.

vannnnish avatar vannnnish commented on June 3, 2024

You are right. I got the problem because of the wrong IP address.
And now , I have a little question.
How to make the command "send2c" work?

First I use dialogs get the use information (and channel too).

 "User": {
          "Flags": 1111,
          "Id": *********,
          "AccessHash": ************,
          "FirstName": "韩",
          "LastName": "ζ’…ζ’…",
          "Phone": "**********",
          "Status": {
            "Value": {
              "UserStatusOffline": {
                "WasOnline": 1527507502
              }
            }

then I type the Id and AccessHash In . But I only get this error.

2:28 [1143938212-375701389491128197] read: type: mtproto.TL_rpc_result, data: {6560580356725550124 mtproto RPC error: 400 CHANNEL_INVALID}, err: <nil>
2018/05/28 18:42:28 mtproto RPC error: 400 CHANNEL_INVALID

then , I try to send message to channel. but I don't know which one is the Chan_Hash of the channel. So I leave it empty . But got the same error.

from mtproto.

cjongseok avatar cjongseok commented on June 3, 2024

@vannnnish Chan_Hash is your access key to the channel. You can get it from MessagesGetAllChats() with your RPC caller. It returns all the your chat and channel list with their id and hash. It seems now we can close this issue. If it repeats again, don't hesitate to reopen it.

from mtproto.

innovative-sol avatar innovative-sol commented on June 3, 2024

Hi,

Same error here while testing the example. Looks like I am redirected then I get a 404. Pasting the full log below. P.S. I tested and I can telnet to 149.154.165.120:443, I can send commands to it, looks ok.

Kindest regards,
Daniel

2018/07/09 10:41:32 [MM 982103936] start
2018/07/09 10:41:32 [MM 982103936] newsession to 149.154.167.50:443
2018/07/09 10:41:32 [0-4218104289253133233] dial TCP to 149.154.167.50:443
2018/07/09 10:41:34 [0-4218104289253133233] send: start
2018/07/09 10:41:34 [0-4218104289253133233] read: start
2018/07/09 10:41:34 [0-4218104289253133233] send *mtproto.ReqInvokeWithLayer: {"Layer":71,"Query":{"type_url":"type.googleapis.com/mtproto.ReqInitConnection","value":"CP3jExIHVW5rbm93bhoNd2luZG93cy9hbWQ2NCIFMC4wLjEqAmVuOgJlbkIuCix0eXBlLmdvb2dsZWFwaXMuY29tL210cHJvdG8uUmVxSGVscEdldENvbmZpZw=="}}
2018/07/09 10:41:34 [0-4218104289253133233] read: type: mtproto.TL_msg_container, data: {[{6576119321041591297 1 28 {6576119320149339824 66879946401993288 [88 46 232 164 58 244 11 72]}} {6576119321041622017 2 20 {[6576119320149339824]}}]}, err:
2018/07/09 10:41:34 [0-4218104289253133233] send mtproto.TL_msgs_ack: {}
2018/07/09 10:41:34 [0-4218104289253133233] read: type: mtproto.TL_rpc_result, data: {6576119320149339824 Date:1531122094 Expires:1531125582 TestMode:<BoolFalse:<> > ThisDc:2 DcOptions:<Value:<Id:1 IpAddress:"149.154.175.50" Port:443 > > DcOptions:<Value:<Flags:16 Id:1 IpAddress:"149.154.175.50" Port:443 > > DcOptions:<Value:<Flags:1 Id:1 IpAddress:"2001:0b28:f23d:f001:0000:0000:0000:000a" Port:443 > > DcOptions:<Value:<Id:2 IpAddress:"149.154.167.51" Port:443 > > DcOptions:<Value:<Flags:16 Id:2 IpAddress:"149.154.167.51" Port:443 > > DcOptions:<Value:<Flags:1 Id:2 IpAddress:"2001:067c:04e8:f002:0000:0000:0000:000a" Port:443 > > DcOptions:<Value:<Id:3 IpAddress:"149.154.175.100" Port:443 > > DcOptions:<Value:<Flags:16 Id:3 IpAddress:"149.154.175.100" Port:443 > > DcOptions:<Value:<Flags:1 Id:3 IpAddress:"2001:0b28:f23d:f003:0000:0000:0000:000a" Port:443 > > DcOptions:<Value:<Id:4 IpAddress:"149.154.167.92" Port:443 > > DcOptions:<Value:<Flags:16 Id:4 IpAddress:"149.154.167.91" Port:443 > > DcOptions:<Value:<Flags:1 Id:4 IpAddress:"2001:067c:04e8:f004:0000:0000:0000:000a" Port:443 > > DcOptions:<Value:<Flags:2 Id:4 IpAddress:"149.154.165.120" Port:443 > > DcOptions:<Value:<Flags:3 Id:4 IpAddress:"2001:067c:04e8:f004:0000:0000:0000:000b" Port:443 > > DcOptions:<Value:<Flags:1 Id:5 IpAddress:"2001:0b28:f23f:f005:0000:0000:0000:000a" Port:443 > > DcOptions:<Value:<Flags:16 Id:5 IpAddress:"91.108.56.120" Port:443 > > DcOptions:<Value:<Id:5 IpAddress:"91.108.56.105" Port:443 > > ChatSizeMax:200 MegagroupSizeMax:100000 ForwardedCountMax:100 OnlineUpdatePeriodMs:120000 OfflineBlurTimeoutMs:5000 OfflineIdleTimeoutMs:30000 OnlineCloudTimeoutMs:300000 NotifyCloudDelayMs:30000 NotifyDefaultDelayMs:1500 ChatBigSize:10 PushChatPeriodMs:60000 PushChatLimit:2 SavedGifsLimit:200 EditTimeLimit:172800 RatingEDecay:2419200 StickersRecentLimit:30 StickersFavedLimit:5 PinnedDialogsCountMax:5 CallReceiveTimeoutMs:20000 CallRingTimeoutMs:90000 CallConnectTimeoutMs:30000 CallPacketTimeoutMs:10000 MeUrlPrefix:"https://t.me/" }, err:
2018/07/09 10:41:34 [0-4218104289253133233] process: unknown data type *mtproto.PredConfig {{"Date":1531122094,"Expires":1531125582,"TestMode":{"Value":{"BoolFalse":{}}},"ThisDc":2,"DcOptions":[{"Value":{"Id":1,"IpAddress":"149.154.175.50","Port":443}},{"Value":{"Flags":16,"Id":1,"IpAddress":"149.154.175.50","Port":443}},{"Value":{"Flags":1,"Id":1,"IpAddress":"2001:0b28:f23d:f001:0000:0000:0000:000a","Port":443}},{"Value":{"Id":2,"IpAddress":"149.154.167.51","Port":443}},{"Value":{"Flags":16,"Id":2,"IpAddress":"149.154.167.51","Port":443}},{"Value":{"Flags":1,"Id":2,"IpAddress":"2001:067c:04e8:f002:0000:0000:0000:000a","Port":443}},{"Value":{"Id":3,"IpAddress":"149.154.175.100","Port":443}},{"Value":{"Flags":16,"Id":3,"IpAddress":"149.154.175.100","Port":443}},{"Value":{"Flags":1,"Id":3,"IpAddress":"2001:0b28:f23d:f003:0000:0000:0000:000a","Port":443}},{"Value":{"Id":4,"IpAddress":"149.154.167.92","Port":443}},{"Value":{"Flags":16,"Id":4,"IpAddress":"149.154.167.91","Port":443}},{"Value":{"Flags":1,"Id":4,"IpAddress":"2001:067c:04e8:f004:0000:0000:0000:000a","Port":443}},{"Value":{"Flags":2,"Id":4,"IpAddress":"149.154.165.120","Port":443}},{"Value":{"Flags":3,"Id":4,"IpAddress":"2001:067c:04e8:f004:0000:0000:0000:000b","Port":443}},{"Value":{"Flags":1,"Id":5,"IpAddress":"2001:0b28:f23f:f005:0000:0000:0000:000a","Port":443}},{"Value":{"Flags":16,"Id":5,"IpAddress":"91.108.56.120","Port":443}},{"Value":{"Id":5,"IpAddress":"91.108.56.105","Port":443}}],"ChatSizeMax":200,"MegagroupSizeMax":100000,"ForwardedCountMax":100,"OnlineUpdatePeriodMs":120000,"OfflineBlurTimeoutMs":5000,"OfflineIdleTimeoutMs":30000,"OnlineCloudTimeoutMs":300000,"NotifyCloudDelayMs":30000,"NotifyDefaultDelayMs":1500,"ChatBigSize":10,"PushChatPeriodMs":60000,"PushChatLimit":2,"SavedGifsLimit":200,"EditTimeLimit":172800,"RatingEDecay":2419200,"StickersRecentLimit":30,"StickersFavedLimit":5,"PinnedDialogsCountMax":5,"CallReceiveTimeoutMs":20000,"CallRingTimeoutMs":90000,"CallConnectTimeoutMs":30000,"CallPacketTimeoutMs":10000,"MeUrlPrefix":"https://t.me/"}}
2018/07/09 10:41:34 [0-4218104289253133233] help config: {"Date":1531122094,"Expires":1531125582,"TestMode":{"Value":{"BoolFalse":{}}},"ThisDc":2,"DcOptions":[{"Value":{"Id":1,"IpAddress":"149.154.175.50","Port":443}},{"Value":{"Flags":16,"Id":1,"IpAddress":"149.154.175.50","Port":443}},{"Value":{"Flags":1,"Id":1,"IpAddress":"2001:0b28:f23d:f001:0000:0000:0000:000a","Port":443}},{"Value":{"Id":2,"IpAddress":"149.154.167.51","Port":443}},{"Value":{"Flags":16,"Id":2,"IpAddress":"149.154.167.51","Port":443}},{"Value":{"Flags":1,"Id":2,"IpAddress":"2001:067c:04e8:f002:0000:0000:0000:000a","Port":443}},{"Value":{"Id":3,"IpAddress":"149.154.175.100","Port":443}},{"Value":{"Flags":16,"Id":3,"IpAddress":"149.154.175.100","Port":443}},{"Value":{"Flags":1,"Id":3,"IpAddress":"2001:0b28:f23d:f003:0000:0000:0000:000a","Port":443}},{"Value":{"Id":4,"IpAddress":"149.154.167.92","Port":443}},{"Value":{"Flags":16,"Id":4,"IpAddress":"149.154.167.91","Port":443}},{"Value":{"Flags":1,"Id":4,"IpAddress":"2001:067c:04e8:f004:0000:0000:0000:000a","Port":443}},{"Value":{"Flags":2,"Id":4,"IpAddress":"149.154.165.120","Port":443}},{"Value":{"Flags":3,"Id":4,"IpAddress":"2001:067c:04e8:f004:0000:0000:0000:000b","Port":443}},{"Value":{"Flags":1,"Id":5,"IpAddress":"2001:0b28:f23f:f005:0000:0000:0000:000a","Port":443}},{"Value":{"Flags":16,"Id":5,"IpAddress":"91.108.56.120","Port":443}},{"Value":{"Id":5,"IpAddress":"91.108.56.105","Port":443}}],"ChatSizeMax":200,"MegagroupSizeMax":100000,"ForwardedCountMax":100,"OnlineUpdatePeriodMs":120000,"OfflineBlurTimeoutMs":5000,"OfflineIdleTimeoutMs":30000,"OnlineCloudTimeoutMs":300000,"NotifyCloudDelayMs":30000,"NotifyDefaultDelayMs":1500,"ChatBigSize":10,"PushChatPeriodMs":60000,"PushChatLimit":2,"SavedGifsLimit":200,"EditTimeLimit":172800,"RatingEDecay":2419200,"StickersRecentLimit":30,"StickersFavedLimit":5,"PinnedDialogsCountMax":5,"CallReceiveTimeoutMs":20000,"CallRingTimeoutMs":90000,"CallConnectTimeoutMs":30000,"CallPacketTimeoutMs":10000,"MeUrlPrefix":"https://t.me/"}
2018/07/09 10:41:34 [0-4218104289253133233] notify Event, mtproto.SessionEstablished: {}, to [0xc042066180]
2018/07/09 10:41:34 [0-4218104289253133233] ping: start
2018/07/09 10:41:34 [MM 982103936] session established 4218104289253133233
2018/07/09 10:41:34 [MM 982103936] connectionOpened 628001342
2018/07/09 10:41:34 [mconn 628001342] start
2018/07/09 10:41:34 [mconn 628001342] opened.
2018/07/09 10:41:34 [mconn 628001342] wait for a session binding ...
2018/07/09 10:41:34 [mconn 628001342] bind: mconn.discardedUpdatesState is nil
2018/07/09 10:41:34 [MM 982103936] sessionBound: session 4218104289253133233 is bound to mconn 628001342
2018/07/09 10:41:34 [mconn 628001342] bound to session 4218104289253133233
2018/07/09 10:41:34 [628001342-4218104289253133233] send mtproto.TL_msgs_ack: {}
2018/07/09 10:41:35 [628001342-4218104289253133233] send *mtproto.ReqAuthSendCode: {"Flags":1,"PhoneNumber":"+40722555555","CurrentNumber":{"Value":{"BoolTrue":{}}},"ApiId":324555,"ApiHash":"xxxxxxxxxxxxxxx"}
2018/07/09 10:41:35 [628001342-4218104289253133233] read: type: mtproto.TL_rpc_result, data: {6576119324971651720 mtproto RPC error: 303 PHONE_MIGRATE_4}, err:
2018/07/09 10:41:35 [628001342-4218104289253133233] send mtproto.TL_msgs_ack: {}
2018/07/09 10:41:35 [MM 982103936] renewSession to 149.154.165.120:443
2018/07/09 10:41:35 [628001342-4218104289253133233] notify Event, mtproto.discardSession: {}, to [0xc042066180 0xc0421fc240]
2018/07/09 10:41:35 [mconn 628001342] session(4218104289253133233) will be discarded
2018/07/09 10:41:35 [mconn 628001342] unbound to session 4218104289253133233
2018/07/09 10:41:35 [MM 982103936] discard session 4218104289253133233
2018/07/09 10:41:35 [MM 982103936] sessionUnbound: session 4218104289253133233 is unbound from mconn 628001342
2018/07/09 10:41:36 [628001342-4218104289253133233] send: stop
2018/07/09 10:41:36 [628001342-4218104289253133233] read: type: , data: , err: read tcp 46.166.173.195:49305->149.154.167.50:443: use of closed network connection
2018/07/09 10:41:36 [628001342-4218104289253133233] read: TCP connection closed (read tcp 46.166.173.195:49305->149.154.167.50:443: use of closed network connection)
2018/07/09 10:41:36 [628001342-4218104289253133233] read: wait for inner routine ...
2018/07/09 10:41:36 [628001342-4218104289253133233] read: stop
2018/07/09 10:41:36 [628001342-4218104289253133233] notify Event, mtproto.SessionDiscarded: {}, to [0xc042066180 0xc0421fc240]
2018/07/09 10:41:36 [MM 982103936] session is discarded. keep its updates state, (json): {}
2018/07/09 10:41:36 [MM 982103936] renewRoutine: req newsession
2018/07/09 10:41:36 [MM 982103936] newsession to 149.154.165.120:443
2018/07/09 10:41:36 [MM 982103936] session discarded 4218104289253133233
2018/07/09 10:41:36 [0-6772078815125579951] dial TCP to 149.154.165.120:443
2018/07/09 10:41:37 [MM 982103936] connect failure: Server response error: -404
2018/07/09 10:41:37 [MM 982103936] renewSession failure: cannot connect to 149.154.165.120:443. Server response error: -404

from mtproto.

cjongseok avatar cjongseok commented on June 3, 2024

@innovative-sol thanks for your interest in this project. It seems mtproto redirects your session to the wrong server, 149.154.165.120. PHONE_MIGRATE_X means redirect the session to the server whose ID is X. Although the ID of 149.154.165.120 is also 4, it seems your session needs to redirect to the different one (I think 149.154.167.92) with the same ID but flag. I will patch it to connect the server with the higher flag now.

If you want to test the different server right away, just change the ip field in your generated credentials file credentials.json to 149.154.167.92, and then run go run examples/simpleshell/main.go credentials.json

from mtproto.

innovative-sol avatar innovative-sol commented on June 3, 2024

Hi,

Thanks a lot for the fast reply! Updated the IP as you suggested and got this:

2018/07/09 11:49:21 [MM 2069938044] start
2018/07/09 11:49:21 [MM 2069938044] loadsession of conn 0
2018/07/09 11:49:21 [0-5135375494467832145] dial TCP to 149.154.167.92:443
2018/07/09 11:49:21 [0-5135375494467832145] send: start
2018/07/09 11:49:21 [0-5135375494467832145] send *mtproto.ReqInvokeWithLayer: {"Layer":71,"Query":{"type_url":"type.googleapis.com/mtproto.ReqInitConnection","value":"xxxxxxxxxxxxxxx3bhoNd2luZG93cy9hbWQ2NCIFMC4wLjEqAmVuOgJlbkIuCix0eXBlLmdvb2dsZWFwaXMuY29tL210cHJvdG8uUmVxSGVscEdldENvbmZpZw=="}}
2018/07/09 11:49:21 [0-5135375494467832145] read: start
2018/07/09 11:49:21 [0-5135375494467832145] read: type: , data: , err: Server response error: -404
2018/07/09 11:49:21 [0-5135375494467832145] read: unknown error, Server response error: -404. reconnect to 149.154.167.92:443
2018/07/09 11:49:21 [0-5135375494467832145] notify Event, mtproto.refreshSession: {}, to [0xc042066120]
2018/07/09 11:49:21 [MM 2069938044] refreshSession 5135375494467832145
2018/07/09 11:49:22 [MM 2069938044] spinlocked. Session(5135375494467832145) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 11:49:23 [MM 2069938044] spinlocked. Session(5135375494467832145) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 11:49:24 [MM 2069938044] spinlocked. Session(5135375494467832145) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 11:49:25 [MM 2069938044] spinlocked. Session(5135375494467832145) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 11:49:26 [MM 2069938044] spinlocked. Session(5135375494467832145) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 11:49:27 [MM 2069938044] spinlocked. Session(5135375494467832145) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 11:49:28 [MM 2069938044] spinlocked. Session(5135375494467832145) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 11:49:29 [MM 2069938044] spinlocked. Session(5135375494467832145) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 11:49:30 [MM 2069938044] spinlocked. Session(5135375494467832145) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 11:49:31 [MM 2069938044] connect failure: Handshaking Failure: TL_invokeWithLayer Timeout(10.000000 s)
2018/07/09 11:49:31 [0-5135375494467832145] send: stop
2018/07/09 11:49:31 [0-5135375494467832145] read: wait for inner routine ...
2018/07/09 11:49:31 [0-5135375494467832145] read: stop
2018/07/09 11:49:31 [0-5135375494467832145] notify Event, mtproto.SessionDiscarded: {}, to [0xc042066120]
2018/07/09 11:49:31 [MM 2069938044] session discarded 5135375494467832145

from mtproto.

cjongseok avatar cjongseok commented on June 3, 2024

@innovative-sol oh no. thanks for the fast try. Can you also try 149.154.167.91 whose ID is same but much higher flag(16)? This server is the last one with the same ID.

from mtproto.

innovative-sol avatar innovative-sol commented on June 3, 2024

Tried now! Same result unfortunately...

2018/07/09 12:05:40 [MM 672018069] start
2018/07/09 12:05:40 [MM 672018069] loadsession of conn 0
2018/07/09 12:05:40 [0-5900156025972631235] dial TCP to 149.154.167.91:443
2018/07/09 12:05:40 [0-5900156025972631235] send: start
2018/07/09 12:05:40 [0-5900156025972631235] read: start
2018/07/09 12:05:40 [0-5900156025972631235] send *mtproto.ReqInvokeWithLayer: {"Layer":71,"Query":{"type_url":"type.googleapis.com/mtproto.ReqInitConnection","value":"xxxxxxxxxxxxxxx3bhoNd2luZG93cy9hbWQ2NCIFMC4wLjEqAmVuOgJlbkIuCix0eXBlLmdvb2dsZWFwaXMuY29tL210cHJvdG8uUmVxSGVscEdldENvbmZpZw=="}}
2018/07/09 12:05:40 [0-5900156025972631235] read: type: , data: , err: Server response error: -404
2018/07/09 12:05:40 [0-5900156025972631235] read: unknown error, Server response error: -404. reconnect to 149.154.167.91:443
2018/07/09 12:05:40 [0-5900156025972631235] notify Event, mtproto.refreshSession: {}, to [0xc042066120]
2018/07/09 12:05:40 [MM 672018069] refreshSession 5900156025972631235
2018/07/09 12:05:41 [MM 672018069] spinlocked. Session(5900156025972631235) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 12:05:42 [MM 672018069] spinlocked. Session(5900156025972631235) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 12:05:43 [MM 672018069] spinlocked. Session(5900156025972631235) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 12:05:44 [MM 672018069] spinlocked. Session(5900156025972631235) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 12:05:45 [MM 672018069] spinlocked. Session(5900156025972631235) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 12:05:46 [MM 672018069] spinlocked. Session(5900156025972631235) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 12:05:47 [MM 672018069] spinlocked. Session(5900156025972631235) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 12:05:48 [MM 672018069] spinlocked. Session(5900156025972631235) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 12:05:49 [MM 672018069] spinlocked. Session(5900156025972631235) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 12:05:50 [MM 672018069] connect failure: Handshaking Failure: TL_invokeWithLayer Timeout(10.000000 s)
2018/07/09 12:05:50 [0-5900156025972631235] send: stop
2018/07/09 12:05:50 [0-5900156025972631235] read: wait for inner routine ...
2018/07/09 12:05:50 [0-5900156025972631235] read: stop
2018/07/09 12:05:50 [0-5900156025972631235] notify Event, mtproto.SessionDiscarded: {}, to [0xc042066120]

from mtproto.

cjongseok avatar cjongseok commented on June 3, 2024

@innovative-sol I think the remained option we can try is touching 149.154.167.91 and 149.154.167.92 again from the scratch. I will let you know when the code is ready.

And if you can try telegram desktop application on the same machine, it can give more hints.

from mtproto.

innovative-sol avatar innovative-sol commented on June 3, 2024

I just installed Telegram Desktop on my machine. I also tested with the ..92 IP address - same result.

2018/07/09 12:40:15 [MM 81822611] start
2018/07/09 12:40:15 [MM 81822611] loadsession of conn 0
2018/07/09 12:40:15 [0-3611346300878101625] dial TCP to 149.154.167.92:443
2018/07/09 12:40:15 [0-3611346300878101625] send: start
2018/07/09 12:40:15 [0-3611346300878101625] read: start
2018/07/09 12:40:15 [0-3611346300878101625] send *mtproto.ReqInvokeWithLayer: {"Layer":71,"Query":{"type_url":"type.googleapis.com/mtproto.ReqInitConnection","value":"xxxxxxxxxxxxxxx3bhoNd2luZG93cy9hbWQ2NCIFMC4wLjEqAmVuOgJlbkIuCix0eXBlLmdvb2dsZWFwaXMuY29tL210cHJvdG8uUmVxSGVscEdldENvbmZpZw=="}}
2018/07/09 12:40:15 [0-3611346300878101625] read: type: , data: , err: Server response error: -404
2018/07/09 12:40:15 [0-3611346300878101625] read: unknown error, Server response error: -404. reconnect to 149.154.167.92:443
2018/07/09 12:40:15 [0-3611346300878101625] notify Event, mtproto.refreshSession: {}, to [0xc042066120]
2018/07/09 12:40:15 [MM 81822611] refreshSession 3611346300878101625
2018/07/09 12:40:16 [MM 81822611] spinlocked. Session(3611346300878101625) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 12:40:17 [MM 81822611] spinlocked. Session(3611346300878101625) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 12:40:18 [MM 81822611] spinlocked. Session(3611346300878101625) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 12:40:19 [MM 81822611] spinlocked. Session(3611346300878101625) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 12:40:20 [MM 81822611] spinlocked. Session(3611346300878101625) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 12:40:21 [MM 81822611] spinlocked. Session(3611346300878101625) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 12:40:22 [MM 81822611] spinlocked. Session(3611346300878101625) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 12:40:23 [MM 81822611] spinlocked. Session(3611346300878101625) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 12:40:24 [MM 81822611] spinlocked. Session(3611346300878101625) is waiting for a response from either invokeWithLayer or updatesGetState.
2018/07/09 12:40:25 [MM 81822611] connect failure: Handshaking Failure: TL_invokeWithLayer Timeout(10.000000 s)
2018/07/09 12:40:25 [0-3611346300878101625] send : null
2018/07/09 12:40:25 [0-3611346300878101625] send : null
2018/07/09 12:40:25 [0-3611346300878101625] send: stop
2018/07/09 12:40:25 [0-3611346300878101625] read: wait for inner routine ...
2018/07/09 12:40:25 [0-3611346300878101625] read: stop
2018/07/09 12:40:25 [0-3611346300878101625] notify Event, mtproto.SessionDiscarded: {}, to [0xc042066120]
2018/07/09 12:40:25 [MM 81822611] session discarded 3611346300878101625

from mtproto.

cjongseok avatar cjongseok commented on June 3, 2024

@innovative-sol I could notice that the server with flags 0 would be for APIs over HTTPS, because flags mean the sum of below options:

	dcOptionFlagIPv6 = 0 // means 2^0
	dcOptionFlagMediaOnly = 1
	dcOptionFlagTcpOnly = 2
	dcOptionFlagCDN = 3
	dcOptionFlagStatic = 4

So the above commit selects the DC with flags 0. If it does not work you can manually inject the desired flags at session.go:1082 where I commented in the commit. If none of servers work, I guess it would be the issue on the server side.

When you try it, please run it from scratch; run go run examples/simpleshell/main.go <APIID> <APIHASH> <PHONE> <IP> <PORT> instead of go run examples/simpleshell/main.go <JSON_FILE>.

The commit is on fix_dc_migration branch.

from mtproto.

cjongseok avatar cjongseok commented on June 3, 2024

You tried Telegram Desktop! Thanks :). The Telegram Desktop worked on your machine? The reason why I asked you to try it was to make sure the Telegram servers are working with your machine, because it would also migrate your session to the same DC ID.

from mtproto.

cjongseok avatar cjongseok commented on June 3, 2024

@innovative-sol Cool! Then I can merge it to the main branch. Thanks for your participation in this project.

from mtproto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.