TelegramMessenger / MTProxy

4.97k stars 819 forks source link

My server not working anymore with MTProxy! #302

Open s4miii opened 5 years ago

s4miii commented 5 years ago

couple of months ago, I installed Docker 18.09 on my Linux Server,

4.4.0-145-generic #171-Ubuntu SMP Tue Mar 26 12:43:40 UTC 2019

Then I used this proxy for Telegram app,

docker run -d -p3032:443 --name=myprx --restart=always -v proxy-config:/data -e SECRET= 1ecefa19430cff07d62f69d5ad61b9dd telegrammessenger/proxy:latest

it was working very well, but suddenly it stop working, I even checked netstat result :

tcp6 0 0 :::3032 :::* LISTEN 7090/docker-proxy

and docker :

82a4136a08c0 telegrammessenger/proxy:latest "/bin/sh -c '/bin/ba…" 10 minutes ago Up 10 minutes 0.0.0.0:3032->443/tcp myprx

and this is a log file of current container :

docker logs myprx
####
#### Telegram Proxy
####

[+] Using the explicitly passed secret: '1ecefa19430cff07d62f69d5ad61b9dd'.
[*] Final configuration:
[*]   Secret 1: 1ecefa19430cff07d62f69d5ad61b9dd
[*]   tg:// link for secret 1 auto configuration: tg://proxy?server=[MY-IP-ADDRESS]&port=443&secret=1ecefa19430cff07d62f69d5ad61b9dd
[*]   t.me link for secret 1: https://t.me/proxy?server=[MY-IP-ADDRESS]&port=443&secret=1ecefa19430cff07d62f69d5ad61b9dd
[*]   Tag: no tag
[*]   External IP: [MY-IP-ADDRESS]
[*]   Make sure to fix the links in case you run the proxy on a different port.

[+] Starting proxy...
[6][2019-05-27 09:39:09.535070 local] Invoking engine mtproxy-0.01 compiled at Jan 25 2019 10:50:53 by gcc 4.9.2 64-bit after commit 2c942119c4ee340c80922ba11d14fb3b10d5e654
[6][2019-05-27 09:39:09.535719 local] config_filename = '/etc/telegram/backend.conf'
[6][2019-05-27 09:39:09.536904 local] creating 2 workers
[34][2019-05-27 09:39:09.543192 local] Started as [172.17.0.2:2398:34:1558949949]
[34][2019-05-27 09:39:09.544037 local] configuration file /etc/telegram/backend.conf re-read successfully (809 bytes parsed), new configuration active
[34][2019-05-27 09:39:09.544187 local] main loop
[6][2019-05-27 09:39:09.545853 local] Started as [172.17.0.2:2398:6:1558949949]
[6][2019-05-27 09:39:09.548571 local] configuration file /etc/telegram/backend.conf re-read successfully (809 bytes parsed), new configuration active
[6][2019-05-27 09:39:09.548654 local] main loop
[35][2019-05-27 09:39:09.549558 local] Started as [172.17.0.2:2398:35:1558949949]
[35][2019-05-27 09:39:09.550591 local] configuration file /etc/telegram/backend.conf re-read successfully (809 bytes parsed), new configuration active
[35][2019-05-27 09:39:09.550877 local] main loop

then I've done :

but nothing happened , any idea ?

Solbadguy commented 5 years ago

Experiencing the same problems

I will add

docker exec mtproto-proxy curl http://localhost:2398/stats curl: (7) Failed to connect to localhost port 2398: Connection refused

7urkm3n commented 5 years ago

@s4miii @Solbadguy Did you guys solve this ?

Recently installed and telegram not connecting at all. Curling

curl: (7) Failed to connect to localhost port {PORT}: Connection refused

ssitdikov commented 5 years ago

Me too. Subscribe

ghost commented 4 years ago

It also happened for me today, apparently the fix from the issue 197 ( https://github.com/TelegramMessenger/MTProxy/issues/197#issuecomment-444445643 ) worked great, I have a debian 10 machine and changed /etc/systemd/timesyncd.conf to include a ntp server, then executed timedatectl set-ntp true, restarted the mtproto proxy and now it works flawlessly.

naderjafari commented 2 years ago

Try: https://ru.stackoverflow.com/questions/984039/%D0%A1%D0%B1%D0%BE%D1%80-%D1%81%D1%82%D0%B0%D1%82%D0%B8%D1%81%D1%82%D0%B8%D0%BA%D0%B8-mtproto-proxy

rc5hack commented 6 months ago

Let's assume MTProxy is started using docker compose with the following configuration file:

version: '2.4'

services:
  tgproxy:
    image: telegrammessenger/proxy:1.4
    volumes:
      - ./proxy-config:/data
    ports:
      - 0.0.0.0:443:443
    restart: unless-stopped

After running the container "as is", localhost:2398/stats endpoint does not respond:

$ docker compose up -d tgproxy
[+] Running 1/2
 ⠸ Network tgproxy_default  Created                                                                    0.4s
 ✔ Container tgproxy        Started                                                                    0.4s

$ docker compose ps tgproxy
NAME      IMAGE                         COMMAND                  SERVICE   CREATED          STATUS          PORTS
tgproxy   telegrammessenger/proxy:1.4   "/bin/sh -c '/bin/ba…"   tgproxy   11 seconds ago   Up 10 seconds   0.0.0.0:443->443/tcp

$ docker compose exec tgproxy curl -4sS http://localhost:2398/stats
curl: (7) Failed to connect to localhost port 2398: Connection refused

How to fix:

$ docker compose exec tgproxy tail -n1 -- /run.sh
exec /usr/local/bin/mtproto-proxy -p 2398 -H 443 -M "$WORKERS" -C 60000 --aes-pwd /etc/telegram/hello-explorers-how-are-you-doing -u root $CONFIG --allow-skip-dh --nat-info "$INTERNAL_IP:$IP" $SECRET_CMD $TAG_CMD

$ docker compose exec tgproxy sed -E -i -- "/--http-stats/! s#(/usr/local/bin/mtproto-proxy)#\1 --http-stats#" /run.sh

$ docker compose exec tgproxy tail -n1 -- /run.sh
exec /usr/local/bin/mtproto-proxy --http-stats -p 2398 -H 443 -M "$WORKERS" -C 60000 --aes-pwd /etc/telegram/hello-explorers-how-are-you-doing -u root $CONFIG --allow-skip-dh --nat-info "$INTERNAL_IP:$IP" $SECRET_CMD $TAG_CMD

$ docker compose exec tgproxy curl -4sS http://localhost:2398/stats
curl: (7) Failed to connect to localhost port 2398: Connection refused

$ docker compose exec tgproxy pkill -9 mtproto-proxy

$ docker compose exec tgproxy curl -4sS http://localhost:2398/stats
pid     7
start_time      1709043377
current_time    1709043378
uptime  1
tot_idle_time   1.454
...

pkill -9 is to force restart.

rc5hack commented 6 months ago

The same answer in Russian: https://ru.stackoverflow.com/a/1569227/177853