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

An existing connection was forcibly closed by the remote host. #6

Closed zkip closed 6 years ago

zkip commented 6 years ago

2018/02/22 13:55:00 MAIN: load authentication 2018/02/22 13:55:00 [MM 1855813799] start 2018/02/22 13:55:00 [MM 1855813799] loadsession of +86** 2018/02/22 13:55:00 [MM 1855813799] connect failure: Cannot Load Session info from neither session file nor env: open new session:%!(EXTRA errors.errorString=New session) 2018/02/22 13:55:00 Cannot Load Session info from neither session file nor env: open new session:%!(EXTRA *errors.errorString=New session) 2018/02/22 13:55:08 MAIN: new authentication 2018/02/22 13:55:08 [MM 1161534771] start 2018/02/22 13:55:08 [MM 1161534771] newsession to 149.154.167.50:443 2018/02/22 13:55:08 [0-196229755453559639] dial TCP to 149.154.167.50:443 2018/02/22 13:55:09 [MM 1161534771] connect failure: write tcp 192.168.0.107:57004->149.154.167.50:443: wsasend: An existing connection was forcibly closed by the remote host. 2018/02/22 13:55:09 write tcp 192.168.0.107:57004->149.154.167.50:443: wsasend: An existing connection was forcibly closed by the remote host.

cjongseok commented 6 years ago

what's your code and environment?

zkip commented 6 years ago

image image

.\simpleshell.exe *** 149.154.167.40:443

cjongseok commented 6 years ago

Can you try it again after removing ${HOME}/.telegram_*** file?

zkip commented 6 years ago

Yes,i tried.This is the result of the trial.

cjongseok commented 6 years ago

oh sorry, please try it again after setting sessionFileHome = ""

cjongseok commented 6 years ago

are you in China?

zkip commented 6 years ago

Yes.

cjongseok commented 6 years ago

Then can you try it over VPN?

zkip commented 6 years ago

Do you mean that I was blocked by a firewall?

cjongseok commented 6 years ago

I think so. There is a case which an application encountered "the connection was forcibly closed" in China but VPN thru Hong Kong. See Ludovic Boudinet's comment on https://archive.sap.com/discussions/thread/3232185

zkip commented 6 years ago

Well, I see. Thank you for your answer.

cjongseok commented 6 years ago

It's my pleasure. If you try it over VPN, please share the result then other guys can refer it. Thank you :)

zkip commented 6 years ago

I will.

zkip commented 6 years ago

But it's strange that I was successful when I Ping the remote host.

zkip commented 6 years ago

Maybe you should add the capability to use a proxy? For example, socks5.

cjongseok commented 6 years ago

Can you check the port 443 is reachable from your PC? On Windows, you can use telnet. see https://www.acronis.com/en-us/articles/telnet/ Unfortunately, I have no plan to add socks5, sorry. I hope VPN would work. If you really need mtproto over socks5, I think you can refer to this open pull request. According to mtproto.go:82-98, it seems you can just alternate net.DialTCP() with socks5.Dial() after socks5 instantiation.

zkip commented 6 years ago

It was true that I was blocked by the firewall, and finally I solved this problem when I used the Socks5 agent.