cjongseok / mtproto

Telegram MTProto and its proxy (over gRPC) in Go (golang). API Layer: 71
Apache License 2.0
151 stars 20 forks source link

Error in handshake #5

Closed parserpro closed 6 years ago

parserpro commented 6 years ago

Log from example application:

2018/01/31 11:16:38 MAIN: load authentication
2018/01/31 11:16:38 [MM 493794111] start
2018/01/31 11:16:38 [MM 493794111] loadsession of  +79689329901
2018/01/31 11:16:38 [0-5104173340106603236] dial TCP to 149.154.167.50:443
2018/01/31 11:16:38 [0-5104173340106603236] read: start
2018/01/31 11:16:38 [0-5104173340106603236] send: start
2018/01/31 11:16:38 [0-5104173340106603236] send mtproto.TL_invokeWithLayer: {"Layer":71,"Query":{"Api_id":35556,"Device_model":"Unknown","System_version":"linux/amd64","App_version":"0.0.1","System_lang_code":"en","Lang_pack":"","Lang_code":"en","Query":{}}}
2018/01/31 11:16:38 [0-5104173340106603236] read: type: mtproto.TL_crc_bad_msg_notification, data: {6517125814043208060 1 17}, err: <nil>
2018/01/31 11:16:38 [0-5104173340106603236] process: unknown data type mtproto.TL_crc_bad_msg_notification {{}}
2018/01/31 11:16:43 [MM 493794111] connect failure: Handshaking Failure: TL_invokeWithLayer Timeout(5.000000 s)
2018/01/31 11:16:43 [0-5104173340106603236] send: stop
2018/01/31 11:16:43 [0-5104173340106603236] read: wait for inner routine ...
2018/01/31 11:16:43 [0-5104173340106603236] read: type: <nil>, data: <nil>, err: read tcp 10.240.32.15:36862->149.154.167.50:443: use of closed network connection
2018/01/31 11:16:43 [0-5104173340106603236] read: TCP connection closed (read tcp 10.240.32.15:36862->149.154.167.50:443: use of closed network connection)
2018/01/31 11:16:43 [0-5104173340106603236] notify MEvent, mtproto.refreshSession: {}, to [0xc420022180]
2018/01/31 11:16:43 [0-5104173340106603236] read: stop
2018/01/31 11:16:43 [0-5104173340106603236] notify MEvent, mtproto.SessionDiscarded: {}, to [0xc420022180]
2018/01/31 11:16:43 [MM 493794111] session discarded  5104173340106603236
2018/01/31 11:16:43 [MM 493794111] refreshSession  5104173340106603236
2018/01/31 11:16:43 ERR: Handshaking Failure: TL_invokeWithLayer Timeout(5.000000 s)

$ go version
go version go1.9.2 linux/amd64

$ uname -a
Linux wks-mishkin 4.4.0-112-generic #135-Ubuntu SMP Fri Jan 19 11:48:36 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
parserpro commented 6 years ago

Sorry, problem was with firewall.

cjongseok commented 6 years ago

Good job. Thanks for your interest in my code :)

parserpro commented 6 years ago

Still have an error:

2018/01/31 15:31:02 MAIN: new authentication
2018/01/31 15:31:02 [MM 36725368] start
2018/01/31 15:31:02 [MM 36725368] newsession to  149.154.167.50:443
2018/01/31 15:31:02 [0-1706807369385595050] dial TCP to 149.154.167.50:443
2018/01/31 15:31:17 [0-1706807369385595050] send: start
2018/01/31 15:31:17 [0-1706807369385595050] read: start
2018/01/31 15:31:17 [0-1706807369385595050] send mtproto.TL_invokeWithLayer: {"Layer":71,"Query":{"Api_id":35556,"Device_model":"Unknown","System_version":"linux/amd64","App_version":"0.0.1","System_lang_code":"en","Lang_pack":"","Lang_code":"en","Query":{}}}
2018/01/31 15:31:17 [0-1706807369385595050] read: type: mtproto.TL_msg_container, data: {[{6517191437164973057 1 28 {6517191436742959112 7044066455704447032 [176 73 76 254 134 113 189 142]}} {6517191437165030401 2 20 {[6517191436742959112]}}]}, err: <nil>
2018/01/31 15:31:17 [0-1706807369385595050] send mtproto.TL_msgs_ack: {}
2018/01/31 15:31:17 [0-1706807369385595050] read: type: mtproto.TL_rpc_result, data: {6517191436742959112 {0 1517401877 1517405743 {} 2 [{0 1 149.154.175.50 443} {1 1 2001:0b28:f23d:f001:0000:0000:0000:000a 443} {0 2 149.154.167.51 443} {16 2 149.154.167.51 443} {1 2 2001:067c:04e8:f002:0000:0000:0000:000a 443} {0 3 149.154.175.100 443} {1 3 2001:0b28:f23d:f003:0000:0000:0000:000a 443} {0 4 149.154.167.91 443} {1 4 2001:067c:04e8:f004:0000:0000:0000:000a 443} {2 4 149.154.165.120 443} {0 5 91.108.56.165 443} {1 5 2001:0b28:f23f:f005:0000:0000:0000:000a 443}] 200 100000 100 120000 5000 30000 300000 30000 1500 10 60000 2 200 172800 2419200 30 5 0 5 20000 90000 30000 10000 https://t.me/  0 []}}, err: <nil>
2018/01/31 15:31:17 [0-1706807369385595050] process: unknown data type mtproto.TL_config {{"Flags":0,"Date":1517401877,"Expires":1517405743,"Test_mode":{},"This_dc":2,"Dc_options":[{"Flags":0,"Id":1,"Ip_address":"149.154.175.50","Port":443},{"Flags":1,"Id":1,"Ip_address":"2001:0b28:f23d:f001:0000:0000:0000:000a","Port":443},{"Flags":0,"Id":2,"Ip_address":"149.154.167.51","Port":443},{"Flags":16,"Id":2,"Ip_address":"149.154.167.51","Port":443},{"Flags":1,"Id":2,"Ip_address":"2001:067c:04e8:f002:0000:0000:0000:000a","Port":443},{"Flags":0,"Id":3,"Ip_address":"149.154.175.100","Port":443},{"Flags":1,"Id":3,"Ip_address":"2001:0b28:f23d:f003:0000:0000:0000:000a","Port":443},{"Flags":0,"Id":4,"Ip_address":"149.154.167.91","Port":443},{"Flags":1,"Id":4,"Ip_address":"2001:067c:04e8:f004:0000:0000:0000:000a","Port":443},{"Flags":2,"Id":4,"Ip_address":"149.154.165.120","Port":443},{"Flags":0,"Id":5,"Ip_address":"91.108.56.165","Port":443},{"Flags":1,"Id":5,"Ip_address":"2001:0b28:f23f:f005:0000:0000:0000:000a","Port":443}],"Chat_size_max":200,"Megagroup_size_max":100000,"Forwarded_count_max":100,"Online_update_period_ms":120000,"Offline_blur_timeout_ms":5000,"Offline_idle_timeout_ms":30000,"Online_cloud_timeout_ms":300000,"Notify_cloud_delay_ms":30000,"Notify_default_delay_ms":1500,"Chat_big_size":10,"Push_chat_period_ms":60000,"Push_chat_limit":2,"Saved_gifs_limit":200,"Edit_time_limit":172800,"Rating_e_decay":2419200,"Stickers_recent_limit":30,"Stickers_faved_limit":5,"Tmp_sessions":0,"Pinned_dialogs_count_max":5,"Call_receive_timeout_ms":20000,"Call_ring_timeout_ms":90000,"Call_connect_timeout_ms":30000,"Call_packet_timeout_ms":10000,"Me_url_prefix":"https://t.me/","Suggested_lang_code":"","Lang_pack_version":0,"Disabled_features":[]}}
2018/01/31 15:31:17 [0-1706807369385595050] config: {"Flags":0,"Date":1517401877,"Expires":1517405743,"Test_mode":{},"This_dc":2,"Dc_options":[{"Flags":0,"Id":1,"Ip_address":"149.154.175.50","Port":443},{"Flags":1,"Id":1,"Ip_address":"2001:0b28:f23d:f001:0000:0000:0000:000a","Port":443},{"Flags":0,"Id":2,"Ip_address":"149.154.167.51","Port":443},{"Flags":16,"Id":2,"Ip_address":"149.154.167.51","Port":443},{"Flags":1,"Id":2,"Ip_address":"2001:067c:04e8:f002:0000:0000:0000:000a","Port":443},{"Flags":0,"Id":3,"Ip_address":"149.154.175.100","Port":443},{"Flags":1,"Id":3,"Ip_address":"2001:0b28:f23d:f003:0000:0000:0000:000a","Port":443},{"Flags":0,"Id":4,"Ip_address":"149.154.167.91","Port":443},{"Flags":1,"Id":4,"Ip_address":"2001:067c:04e8:f004:0000:0000:0000:000a","Port":443},{"Flags":2,"Id":4,"Ip_address":"149.154.165.120","Port":443},{"Flags":0,"Id":5,"Ip_address":"91.108.56.165","Port":443},{"Flags":1,"Id":5,"Ip_address":"2001:0b28:f23f:f005:0000:0000:0000:000a","Port":443}],"Chat_size_max":200,"Megagroup_size_max":100000,"Forwarded_count_max":100,"Online_update_period_ms":120000,"Offline_blur_timeout_ms":5000,"Offline_idle_timeout_ms":30000,"Online_cloud_timeout_ms":300000,"Notify_cloud_delay_ms":30000,"Notify_default_delay_ms":1500,"Chat_big_size":10,"Push_chat_period_ms":60000,"Push_chat_limit":2,"Saved_gifs_limit":200,"Edit_time_limit":172800,"Rating_e_decay":2419200,"Stickers_recent_limit":30,"Stickers_faved_limit":5,"Tmp_sessions":0,"Pinned_dialogs_count_max":5,"Call_receive_timeout_ms":20000,"Call_ring_timeout_ms":90000,"Call_connect_timeout_ms":30000,"Call_packet_timeout_ms":10000,"Me_url_prefix":"https://t.me/","Suggested_lang_code":"","Lang_pack_version":0,"Disabled_features":[]}
2018/01/31 15:31:17 [0-1706807369385595050] send mtproto.TL_msgs_ack: {}
2018/01/31 15:31:18 [0-1706807369385595050] send mtproto.TL_updates_getState: {}
2018/01/31 15:31:18 [0-1706807369385595050] read: type: mtproto.TL_rpc_result, data: {6517191441543161732 mtproto RPC error: 401 AUTH_KEY_UNREGISTERED}, err: <nil>
2018/01/31 15:31:18 [0-1706807369385595050] process: unknown data type mtproto.TL_rpc_error {{}}
2018/01/31 15:31:18 [MM 36725368] connect failure: TL_updates_getState Failure: mtproto RPC error: 401 AUTH_KEY_UNREGISTERED
2018/01/31 15:31:18 TL_updates_getState Failure: mtproto RPC error: 401 AUTH_KEY_UNREGISTERED

$ go version
go version go1.9.2 linux/amd64

$ uname -a
Linux vmi113961.contaboserver.net 4.8.0-46-generic #49-Ubuntu SMP Fri Mar 31 13:57:14 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

I'm using this ID and HASH in another app and all works fine, so the problem is not here.

cjongseok commented 6 years ago

It seems that a dummy ${HOME}/.telegram_xxx file generated by your first blocked trial is obstructing the normal sign-in procedure. On the initial run of examples/simpleshell, it signs in to Telegram with your phone number, and stores the access token in ${HOME}/.telegram_xxx file. Please try examples/simpleshell again after removing ${HOME}/.telegram_xxx file. Then Telegram will send you a verification code.

parserpro commented 6 years ago

Nothing has changed. The same error. And no request for phone number.

cjongseok commented 6 years ago

'no request for phone number' means you didn't provide your phone number to the program? If so, can you make sure you have tried examples/simpleshell with valid phone number, which is signed up to Telegram? Its usage is: USAGE: go run examples/simpleshell/simpleshell.go APIID APIHASH PHONE ADDR

APIID means Telegram API id. If you do not have it yet, go https://my.telegram.org/apps APIHASH means hashcode of . It is published together with API id. PHONE means phone number in international format w/o hyphen. e.g., +15417543010 ADDR means preffered Telegram server address in the form of :. You can find a vaild address in your https://my.telegram.org/apps page

soin08 commented 6 years ago

I'm having the same problem as @parserpro: TL_updates_getState Failure: mtproto RPC error: 401 AUTH_KEY_UNREGISTERED when trying to run simpleshell.go. ID and HASH are valid.

cjongseok commented 6 years ago

Can you make sure you signed-up to Telegram on mobile? If so, please try it again after removing ${HOME}/.telegram_*** file. If it still doesn't work, let me know with your environment (e.g., OS, Go version, ...).

soin08 commented 6 years ago

@cjongseok Just tested with a fresh Telegram account. Same problem. I'm on Windows 10 x64, Go version 1.10 (also tried on 1.9.2)

> 2018/02/23 16:15:25 [0-2392731273123042348] send mtproto.TL_msgs_ack: {}
> 2018/02/23 16:15:26 [0-2392731273123042348] send mtproto.TL_updates_getState: {}
> 2018/02/23 16:15:26 [0-2392731273123042348] read: type: mtproto.TL_rpc_result, data: {6525737773792695696 mtproto RPC error: 401 AUTH_KEY_UNREGISTERED}, err: <nil>
> 2018/02/23 16:15:26 [0-2392731273123042348] process: unknown data type mtproto.TL_rpc_error {{}}
> 2018/02/23 16:15:26 [MM 1808920179] connect failure: Handshaking Failure: TL_updates_getState Failure: mtproto RPC error: 401 AUTH_KEY_UNREGISTERED
cjongseok commented 6 years ago

@soin08 @parserpro Sorry for that. I have just fixed the issue. Please try the new version.

soin08 commented 6 years ago

@cjongseok issue is fixed, thank you!