Skip to content

Commit 0f042b2

Browse files
authored
Merge pull request #118 from centuriononon/feat/configurable-api-timeouts
Make core API HTTP timeout configurable
2 parents 0180d7e + 60866a6 commit 0f042b2

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/mtp_config.erl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,9 @@ http_get(Url) ->
309309
UserAgent = ("MTProtoProxy/" ++ Vsn ++ " OTP-" ++ OtpVersion ++
310310
" (+https://github.com/seriyps/mtproto_proxy)"),
311311
Headers = [{"User-Agent", UserAgent}],
312+
Timeout = application:get_env(mtproto_proxy, core_api_http_timeout_ms, 3000),
312313
{ok, {{_, 200, _}, _, Body}} =
313-
httpc:request(get, {Url, Headers}, [{timeout, 3000}], ?OPTS),
314+
httpc:request(get, {Url, Headers}, [{timeout, Timeout}], ?OPTS),
314315
{ok, Body}.
315316

316317
random_choice(L) ->

src/mtproto_proxy.app.src

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@
154154
%% Mostly used to testing
155155
%% {proxy_secret_url, "https://core.telegram.org/getProxySecret"},
156156
%% {proxy_config_url, "https://core.telegram.org/getProxyConfig"},
157+
%% HTTP timeout (ms) for fetching proxy config/secret
158+
{core_api_http_timeout_ms, 3000}
157159

158160
%% Upstream self-healthchecks tuning
159161
%% {upstream_healthchecks,

0 commit comments

Comments
 (0)