mtprotoproxy icon indicating copy to clipboard operation
mtprotoproxy copied to clipboard

Why ping so hight?

Open mx256 opened this issue 4 years ago • 7 comments

Hello, im use ovh.ca vps, the cheapest price (OpenStack KVM, 1 vCore(s) From 2 GHz, 2 GB RAM, 20 GB SSD) my ping, from terminal - avg 52ms ping in android messenger (on some wifi and place): erlang realization 60-100ms python 200+ oficial proxy i could not understand, how ON ee (tls) mode

mx256 avatar Nov 08 '19 15:11 mx256

Hello, this is because we use different methods to open tcp connections. Erlang proxy and the official one use preopened tcp connections, which is a bit faster.

I added logic to use preopened connection too: https://github.com/alexbers/mtprotoproxy/commit/e436792992e886b537115c957dea7c4b9f1d70ff and https://github.com/alexbers/mtprotoproxy/commit/8c15fc8fe0d39c98d2dff2deaf1368d660d8bbfb. Please, retry with the lattest master, it should be better

alexbers avatar Nov 11 '19 23:11 alexbers

git clone -b master https://github.com/alexbers/mtprotoproxy.git Run with old config.py, without docker No see changes

mx256 avatar Nov 12 '19 17:11 mx256

I added logic to use preopened connection too: e436792 and 8c15fc8. Please, retry with the lattest master, it should be better

Thank you for those changes, I see some difference.

skipik avatar Nov 12 '19 17:11 skipik

Any benchmarks ?

iShift avatar Nov 12 '19 17:11 iShift

mx256: please make sure that you restarted the proxy. And, please, update again - more changes are made to make the proxy connection faster

iShift: I launched the proxy in San-Francisco server which is far away from the telegram server. I measured the ping time using the telegram client. I've got the following results:

python proxy, no ad: 529ms -> 371ms
python proxy, ad: 814ms -> 661ms -> 510ms -> 374ms
official proxy: 372ms
erlang proxy: 368ms
go proxy: 517ms

alexbers avatar Nov 12 '19 22:11 alexbers

Some config options might reduce ping and make your proxy a little bit faster also. I use something like this, for example:

SECURE_ONLY = True
PREFER_IPV6 = False
FAST_MODE = True
STATS_PRINT_PERIOD = 600
PROXY_INFO_UPDATE_PERIOD = 24*60*60
TO_CLT_BUFSIZE = 163840
TO_TG_BUFSIZE = 655360
CLIENT_KEEPALIVE = 60*60
CLIENT_HANDSHAKE_TIMEOUT = 10
CLIENT_ACK_TIMEOUT = 5*60
TG_CONNECT_TIMEOUT = 10
LISTEN_ADDR_IPV4 = "0.0.0.0"
LISTEN_ADDR_IPV6 = "::"

skipik avatar Nov 13 '19 20:11 skipik

checking again, with this cfg:

PORT = 8883

# name -> secret (32 hex chars)
USERS = {
    "": "",

}

# Makes the proxy harder to detect
# Can be incompatible with very old clients
SECURE_ONLY = True

# Makes the proxy even more hard to detect
# Compatible only with the recent clients
TLS_ONLY = True

# The domain for TLS, bad clients are proxied there
# Use random existing domain, proxy checks it on start
TLS_DOMAIN = "www.cloudflare.com"

# Tag for advertising, obtainable from @MTProxybot
# AD_TAG = "3c09c680b76ee91a4c25ad51f742267d"

PREFER_IPV6 = False
FAST_MODE = True
STATS_PRINT_PERIOD = 600
PROXY_INFO_UPDATE_PERIOD = 24*60*60
TO_CLT_BUFSIZE = 163840
TO_TG_BUFSIZE = 655360
CLIENT_KEEPALIVE = 60*60
CLIENT_HANDSHAKE_TIMEOUT = 10
CLIENT_ACK_TIMEOUT = 5*60
TG_CONNECT_TIMEOUT = 10
LISTEN_ADDR_IPV4 = "0.0.0.0"
LISTEN_ADDR_IPV6 = "::"

ping still 200+

mx256 avatar Nov 20 '19 23:11 mx256