TelegramMessenger / MTProxy

5.01k stars 831 forks source link

Middle-End Connection refused #70

Open borshevsky opened 6 years ago

borshevsky commented 6 years ago

Hi there!

My mtproto proxy could not connect to telegram middle end servers. Logs look like this:

[13568][2018-06-03 13:27:02.023290 local] got error for tcp socket #28, [149.154.175.100]:8888 : Connection refused [13568][2018-06-03 13:27:02.023362 local] Disconnected from RPC Middle-End (fd=28) [13568][2018-06-03 13:27:02.023425 local] Closing connection socket #28 [13568][2018-06-03 13:27:02.037214 local] got error for tcp socket #81, [149.154.175.50]:8888 : Connection refused

I'm trying to figure out the reason of that but my skills are not enough atm:

$ ping 149.154.175.50 PING 149.154.175.50 (149.154.175.50) 56(84) bytes of data. 64 bytes from 149.154.175.50: icmp_seq=1 ttl=56 time=160 ms 64 bytes from 149.154.175.50: icmp_seq=2 ttl=56 time=155 ms 64 bytes from 149.154.175.50: icmp_seq=3 ttl=56 time=167 ms ^C --- 149.154.175.50 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2003ms rtt min/avg/max/mdev = 155.985/161.288/167.171/4.596 ms

$ telnet 149.154.175.50 8888 Trying 149.154.175.50... telnet: Unable to connect to remote host: Connection refused

Is there any way to understand where the connection is refusing? Is it my provider firewall or something else?

coolermister commented 6 years ago

Almost same issue here https://github.com/TelegramMessenger/MTProxy/issues/56

itsMoji commented 6 years ago

Because of Telegram servers listening on 8888 port ( Check https://core.telegram.org/getProxyConfig ) Make sure port 8888 is open in your firewall (CSF, ip tables, etc...) so your server can connect to Telegram servers

borshevsky commented 6 years ago

8888 is definitely open on host machine. Moreover some of Telegram servers available, but proxy still not working.

$ telnet 91.108.4.133 8888 Trying 91.108.4.133... Connected to 91.108.4.133. Escape character is '^]'. ^CConnection closed by foreign host. $ telnet 149.154.175.50 8888 Trying 149.154.175.50... telnet: Unable to connect to remote host: Connection refused

loskiq commented 6 years ago

@borshevsky what is your OS?

MrTrias commented 6 years ago

os1: debian 8 os2: debian 9

I have the same problems:

[11373][2018-06-08 14:38:05.842044 local] Creating NEW connection to 149.154.175.50:8888
[11372][2018-06-08 14:38:05.842045 local] New connection 176.x.y.z:16055 -> 91.108.4.148:8888
[11372][2018-06-08 14:38:05.842064 local] socket 40: disconnected (epoll_ready=2005), cleaning
[11372][2018-06-08 14:38:05.842079 local] Disconnected from RPC Middle-End (fd=40)
[11372][2018-06-08 14:38:05.842094 local] Creating NEW connection to 149.154.175.50:8888
[11373][2018-06-08 14:38:05.842108 local] New connection 176.x.y.z:2227 -> 149.154.175.50:8888
[11373][2018-06-08 14:38:05.842125 local] Closing connection socket #33
[11372][2018-06-08 14:38:05.842153 local] New connection 176.x.y.z:7871 -> 149.154.175.50:8888
[11372][2018-06-08 14:38:05.842170 local] Closing connection socket #40
[11372][2018-06-08 14:38:05.843744 local] socket 46: disconnected (epoll_ready=2005), cleaning
[11372][2018-06-08 14:38:05.843768 local] Disconnected from RPC Middle-End (fd=46)
[11372][2018-06-08 14:38:05.843789 local] Creating NEW connection to 149.154.162.40:80
[11372][2018-06-08 14:38:05.843858 local] New connection 176.x.y.z:22795 -> 149.154.162.40:80
[11372][2018-06-08 14:38:05.843876 local] Closing connection socket #46
[11373][2018-06-08 14:38:05.843966 local] socket 46: disconnected (epoll_ready=2005), cleaning
[11373][2018-06-08 14:38:05.843982 local] Disconnected from RPC Middle-End (fd=46)
[11373][2018-06-08 14:38:05.843997 local] Creating NEW connection to 149.154.162.25:80
[11373][2018-06-08 14:38:05.844060 local] New connection 176.x.y.z:8979 -> 149.154.162.25:80
[11373][2018-06-08 14:38:05.844075 local] Closing connection socket #46
[11373][2018-06-08 14:38:05.848525 local] socket 55: disconnected (epoll_ready=2005), cleaning
[11373][2018-06-08 14:38:05.848542 local] Disconnected from RPC Middle-End (fd=55)
[11373][2018-06-08 14:38:05.848558 local] Creating NEW connection to 91.108.4.209:8888
[11373][2018-06-08 14:38:05.848620 local] New connection 176.x.y.z:18115 -> 91.108.4.209:8888
[11373][2018-06-08 14:38:05.848636 local] Closing connection socket #55
[11372][2018-06-08 14:38:05.848932 local] socket 45: disconnected (epoll_ready=2005), cleaning
[11372][2018-06-08 14:38:05.848950 local] Disconnected from RPC Middle-End (fd=45)
[11372][2018-06-08 14:38:05.848968 local] Creating NEW connection to 91.108.56.117:8888
[11372][2018-06-08 14:38:05.849031 local] New connection 176.x.y.z:7139 -> 91.108.56.117:8888
[11372][2018-06-08 14:38:05.849048 local] Closing connection socket #45
[11373][2018-06-08 14:38:05.849092 local] socket 85: disconnected (epoll_ready=2005), cleaning
[11373][2018-06-08 14:38:05.849165 local] Disconnected from RPC Middle-End (fd=85)
# telnet 91.108.56.117 8888
Trying 91.108.56.117...
Connected to 91.108.56.117.
Escape character is '^]'.

Connection closed by foreign host.
#
borshevsky commented 6 years ago

@loskiq Distributor ID: Ubuntu Description: Ubuntu 18.04 LTS Release: 18.04 Codename: bionic

fatmob commented 6 years ago

@loskiq Have the same problem. Ubuntu Server 16.04 LTS 64 bit

MrTrias commented 6 years ago

someone could solve this problem?

overm commented 6 years ago

Same problem. Ubuntu Server 16.04 LTS 64 bit. Connection to telegramm servers throw the Tor behind the NAT.

soroush commented 5 years ago

I am having same problem. Port 8888 is open on firewall

OS: CentOS 7.5 Kernel: 3.10.0-957.21.3.el7.x86_64

Part of the log:

[18672][2019-07-10 12:59:28.764169 local] RPC connection #7: [xxx.xxx.xxx.xxx]:53756 -> [xxx.xxx.xxx.xxx]:8888 connected, crypto_flags = 2
[18672][2019-07-10 12:59:28.764181 local] END processing connection 7, flags=33554449
[18672][2019-07-10 12:59:28.764203 local] send/writev() to 7: 44 written out of 44 in 1 chunks
[18672][2019-07-10 12:59:28.764208 local] socket_server_writer: written 44 bytes to 7, flags=0x02000011
[18672][2019-07-10 12:59:28.777721 local] fd=24 state=39 ready=1031 epoll_ready=8197
[18672][2019-07-10 12:59:28.777738 local] socket 24: disconnected (epoll_ready=2005), cleaning
[18672][2019-07-10 12:59:28.777743 local] epoll_del(6,0x00000002,24,0,00000000)
[18672][2019-07-10 12:59:28.777754 local] Disconnected from RPC Middle-End (fd=24)
[18672][2019-07-10 12:59:28.777763 local] Creating NEW connection to xxx.xxx.xxx.xxx:8888
[18672][2019-07-10 12:59:28.777873 local] <25 send buffer was 16384, now 16777216
[18672][2019-07-10 12:59:28.777907 local] >25 receive buffer was 87380, now 16777216
[18672][2019-07-10 12:59:28.778015 local] <25 send buffer was 425984, now 16777216
[18672][2019-07-10 12:59:28.778046 local] >25 receive buffer was 425984, now 16777216
[18672][2019-07-10 12:59:28.778057 local] New connection xxx.xxx.xxx.xxx:53764 -> xxx.xxx.xxx.xxx:8888
[18672][2019-07-10 12:59:28.778062 local] epoll_mod(6,0x00000007,25,25,8000200f)
[18672][2019-07-10 12:59:28.778072 local] Closing connection socket #24
soroush commented 5 years ago

I can not confirm that kernel update has any effects on resolving the issue. Using kernel 5.2 problem exists. On another server with exact same configuration, mtproto works fine

Kernel: 5.2.0-1.el7.elrepo.x86_64

tonimore commented 1 year ago

Same problem. A lot of messages running in the log:

socket #36: disconnected (epoll_ready=2005), cleaning
 Created NEW connection #23 to 91.108.4.189:8888
 New outbound connection #23 81.4.108.145:39974 -> 91.108.4.189:8888
 Closing connection socket #16
 socket #9: disconnected (epoll_ready=2005), cleaning
 socket #43: disconnected (epoll_ready=2005), cleaning
 socket #59: disconnected (epoll_ready=2005), cleaning
 Disconnected from RPC Middle-End (fd=36)
 socket #49: disconnected (epoll_ready=2005), cleaning
 Disconnected from RPC Middle-End (fd=49)
 Created NEW connection #16 to 149.154.175.50:8888
 Disconnected from RPC Middle-End (fd=9)
 Disconnected from RPC Middle-End (fd=43)
 Disconnected from RPC Middle-End (fd=59)
 Created NEW connection #45 to 149.154.175.100:8888
 New outbound connection #16 81.4.108.145:38495 -> 149.154.175.50:8888
 New outbound connection #45 81.4.108.145:40398 -> 149.154.175.100:8888
 Created NEW connection #50 to 149.154.161.144:8888
 Closing connection socket #49
 New outbound connection #50 81.4.108.145:38738 -> 149.154.161.144:8888
 Created NEW connection #55 to 149.154.165.250:8888
 New outbound connection #55 81.4.108.145:44119 -> 149.154.165.250:8888
 Created NEW connection #57 to 91.108.4.189:8888
 New outbound connection #57 81.4.108.145:42241 -> 91.108.4.189:8888
 Closing connection socket #36
 Closing connection socket #9
 Closing connection socket #43
 socket #13: disconnected (epoll_ready=2005), cleaning
 Disconnected from RPC Middle-End (fd=13)
 Created NEW connection #25 to 149.154.175.100:8888

Ubuntu 22, 5.2.0 #1 SMP x86_64 GNU/Linux

No NAT, white IP address Run with: mtproto-proxy -u nobody -p 8888 -H 1443 -S <xxx...xxx> --aes-pwd proxy-secret proxy-multi.conf -M 1 --address <external-ip> -v

Proxy settings panel says that "mtproto: connected" but app itself says endless "Connection To Proxy..."

thebitguru commented 2 weeks ago

@tonimore did you ever figure out what was going on? I am running into the same issue

tonimore commented 2 weeks ago

@tonimore did you ever figure out what was going on? I am running into the same issue No, I just don't need it anymore. But I wanted to try to build and run this in a docker container based on an older OSes.

thebitguru commented 2 weeks ago

Thanks for the quick response, @tonimore!

If others are looking, I also gave up on fixing this, and switched to this Erlang-based implementation.