tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
7.11k stars 1.44k forks source link

"Proxy Authentication Required" error when connecting to HTTP proxy via TDLIB #2995

Closed andreymerchenko closed 3 months ago

andreymerchenko commented 3 months ago

Dear tdlib community,

I am experiencing an issue of specifying some HTTP proxy via tdlib. This occurred for the first time, i.e., there are other HTTP proxies in the system which work fine.

I am able to specify this HTTP proxy in Telegram Desktop official client. And also CURL request with this proxy works from the same host, here is the sample CURL request, which is used to verify it (credentials are replaced): curl -x "http://username:password@host:port" "https://google.com/"

However, in tdlib getting "Proxy Authentication Required" error.

Here is the log output when setting log verbosity level to 5:

[ 3][t 4][1721736210.832123994][ConnectionCreator.cpp:996][#1][!ConnectionCreator][&connections]  [client:0xe8d0ca4a] set timeout in 15.998535 [ 4][t 4][1721736210.832141160][TransparentProxy.cpp:55][#1][!HttpProxy][&proxy]  Begin to connect to proxy [ 4][t 4][1721736210.903120994][HttpProxy.cpp:20][#1][!HttpProxy][&proxy]  Send CONNECT to proxy [ 4][t 4][1721736210.903207063][BufferedFd.h:215][#1][!HttpProxy]  Flush write: +138B[left:0B] [ 4][t 4][1721736210.966809272][HttpProxy.cpp:38][#1][!HttpProxy][&proxy]  Receive CONNECT response of size 0 [ 4][t 4][1721736210.966868162][BufferedFd.h:140][#1][!HttpProxy]  Nothing to write to [fd:335] [ 4][t 4][1721736210.966906309][BufferedFd.h:206][#1][!HttpProxy]  Flush read: +125B[total:125B] [ 4][t 4][1721736210.966931104][HttpProxy.cpp:38][#1][!HttpProxy][&proxy]  Receive CONNECT response of size 125 [ 4][t 4][1721736210.966965198][HttpProxy.cpp:50][#1][!HttpProxy][&proxy]  Failed to connect: Proxy Authentication Required\015\012Proxy-Authenticate: Basic realm=\042proxy\042\015\012Connection: close\015\012Content-Length: 0\015\012\015\012

TdApi.AddProxy API is used to specify the proxy, i.e.:

  var proxyType = new TdApi.ProxyTypeHttp("<username>", "<password>", false);
  var addProxyRequest = new TdApi.AddProxy("<hosy>", <port>, true, proxyType);

Could you, please, advise why such issue may occur?

Thank you.

levlam commented 3 months ago

Check that correct username and password are specified in TdApi.ProxyTypeHttp. The proxy is supposed to work in this case and shouldn't return "407 Proxy Authentication Required".

levlam commented 3 months ago

Could you check whether the proxy works in the latest TDLib version that I have just pushed to Github?

andreymerchenko commented 3 months ago

Hi, levlam, thank you for the fast response!

Yes, correct credentials are passed in TdApi.ProxyTypeHttp, otherwise other HTTP proxies would not work.

I will check this issue on the latest version of tdlib and get back with observations.

Thank you.

andreymerchenko commented 3 months ago

Hi levlam,

I will check this issue on the latest version of tdlib and get back with observations.

The issue is not reproduced on the latest tdlib version, thank you!