telegramdesktop / tdesktop

Telegram Desktop messaging app
https://desktop.telegram.org/
Other
26.35k stars 5.24k forks source link

Proxy reconnect forever after updating to 3.2.6 beta #17316

Closed RafaelLinux closed 2 years ago

RafaelLinux commented 2 years ago

Steps to reproduce

  1. Launch Telegram desktop
  2. Telegram desktop window appears, showing no contacts / conversations (empty panels) and displaying "Reconnecting in 60s .... Try now" forever, counting down from 60s to 0s.

It was just working fine JUST BEFORE update it, but now it doesn't work. We are using a proxy and no changes were done to it.

Expected behaviour

To connect thru proxy, like before update

Actual behaviour

Reconnecting always.

Operating system

openSUSE tumbleweed

Version of Telegram Desktop

3.2.6 beta

Installation source

Static binary from official website

Logs

No response

ilya-fedin commented 2 years ago

A race condition while loading proxy settings was fixed. Are you sure it really connected to your proxy previously? Are you sure your Telegram settings are correct (since there was a race condition, it's possible they were ever incorrect but not really used)?

RafaelLinux commented 2 years ago

I would never have reported this bug if it had not been working perfectly until the update. So, I summarise:

So, in short: Telegram desktop was working perfectly fine using the proxy settings in the "proxy" section of Telegram desktop .... until yesterday's update. A few months ago, something very similar happened after another update, but in that case, Telegram's access to the Internet was intermittent (very often "Reconnect..." but it managed to do so).

ilya-fedin commented 2 years ago

I will repeat: a race condition while reading settings was fixed. So I ask you to carefully re-check your Telegram settings, it's possible that they were not used previously, but the default (using proxy configured in the system) was used. Please do that.

RafaelLinux commented 2 years ago

Before opening this thread, I checked the configuration. The data is correct.I have checked it again as you ask me, and I don't see any change or new option that requires me to reconfigure the proxy access data in Telegram.

I include a screenshot, where you can see that the same proxy configuration I had before, is the one I have now.

imagen

ololoev28 commented 2 years ago

We got the same thing. We have our own Squid HTTP proxy. Updated clients can't connect to it. Non-updated still works

ilya-fedin commented 2 years ago

Can you inspect what goes on with wireshark?

ololoev28 commented 2 years ago

New version of Telegram client does HTTP method CONNECT to my proxy server:

SRC IP: client ip DST IP: proxy ip DST port: 3128

CONNECT proxydomain:3128 HTTP/1.1\r\n

And my proxy answer is:

HTTP/1.1 503 Service Unavailable

There is no any CONNECT request in traffic of old Telegram client.

ilya-fedin commented 2 years ago

so the previous version haven't used the proxy?

ololoev28 commented 2 years ago

Used. But there is no HTTP-request with CONNECT method in traffic between client and proxy.

ilya-fedin commented 2 years ago

tdesktop uses mtproto protocol to connect to its server, AFAIU it means that it can use only CONNECT to make requests via HTTP proxies, so it's not clear to me how it worked previously for you.

ilya-fedin commented 2 years ago

I talked with @john-preston, looks like tdesktop can pretend it connects with HTTP, but that mechanism is active only when proxy is not explicitly set. Looks like due to race condition, tdesktop used your system settings effectively with this pretend mechanism, but now it uses your settings, so this mechanism is not active. In other words, you should to switch to 'Use system proxy' (default) for previous behavior

ololoev28 commented 2 years ago

I set "Use system proxy" and now don't see any traffic between my client and proxy. Because I have no system proxy settings.

ilya-fedin commented 2 years ago

If CONNECT is forbidden on your proxy, how do HTTPS sites work?

ololoev28 commented 2 years ago

My proxy is for Telegram only. So I have to setup HTTPS support in proxy? Ok, I'll try..

ilya-fedin commented 2 years ago

No, you have to setup support for any TCP connections since Telegram uses MTPROTO, not HTTP/HTTPS

RafaelLinux commented 2 years ago

Version 3.2.8 beta still not working (but surprisingly, Telegram is able to warn about new update and it can update without issues, using configured proxy, as it worked before 3.2.6 beta version).

ololoev28 commented 2 years ago

We have to move to socks5 proxy (danted).

ilya-fedin commented 2 years ago

Is this reproducible on other OSes or only on Linux?

RafaelLinux commented 2 years ago

Unfortunately, I have to remind you that something very similar already happened in May this year, that I tried to provide all the necessary information and that it was not given the attention and the minimum good treatment I expected, so I closed the thread myself. https://github.com/telegramdesktop/tdesktop/issues/16284

The problem was the same, after an update, but on that occasion Telegram connected intermittently and managed to connect 1 in N times. On that occasion I stopped using Telegram after the palpable slovenliness of the person who dealt with my incident. Months later, I re-downloaded the latest version of Telegram, and the problem was solved.

I make this comment because it may be related to that problem that was not actively resolved, but probably due to some other change in the code.

ilya-fedin commented 2 years ago

On that occasion I stopped using Telegram after the palpable slovenliness of the person who dealt with my incident.

Well, this is not end user support, so it's expected you know basic things

ilya-fedin commented 2 years ago

I make this comment because it may be related to that problem that was not actively resolved, but probably due to some other change in the code.

There was a race condition introduced while reading proxy settings in June, that's probably why it started to work for you. Now the race condition is fixed and you have this problem again. So, I request you to provide the result of _PX_DEBUG=1 ./Telegram again.

RafaelLinux commented 2 years ago

Output after executing _PX_DEBUG=1 ./Telegram

[ALSOFT] (EE) Failed to set real-time priority for thread: Operation not allowed (1)  

Here, it's asking still for my personal Telegram password. After introduce it, the ouput was only:

error: : cannot open
error: : cannot open
error: : cannot open

And that's all output exactly, while Telegram showing forever "Reconnect ..."

imagen

RafaelLinux commented 2 years ago

Is this reproducible on other OSes or only on Linux?

I tried on same PC using Windows 10 and Telegram Beta 3.2.8 portable for Windows. I also need proxy with authentication to connect to Internet and here is the result:

Telegram works well under both scenarios in Windows

ilya-fedin commented 2 years ago

Maybe it's some Qt regression then, because Telegram uses Qt's cross-platform methods to set proxy, so if it reproduces only on Linux, then something is wrong with Qt's Linux-specific network code

proofy commented 2 years ago

Version 3.3.0 under Linux KDE

With debug on this message appears all the time, if the proxy settings is on system settings Configuration extension is: 20kde_config_extension Ignored list is: Config is: wpad:// Trying to find the PAC using WPAD... WPAD search via: 24dns_alias_wpad_extension PAC found! Unable to find a required pacrunner!

Connection still not working

If I use the same proxy over "Use custom proxy" it also not working without any debug messages.

ilya-fedin commented 2 years ago

There's a Linux-only Qt bug with HTTP proxy authentication, apparently :(

proofy commented 2 years ago

In the system settings of KDE, I had set the proxy to automatic and this worked fine for the system but not for Telegram. Now I have switch to manually settings (KDE) and now it also works with Telegram if I'm using system settings. In the debug message I can see, that Telegram found the right IP of the proxy server. (Telegram read the configuration every second?) So that is a solution for me.

ilya-fedin commented 2 years ago

It works if you set the proxy in the system, but not if you set it in Telegram settings?

proofy commented 2 years ago

I use now manually proxy settings in the systems (KDE) and "Use system proxy settings" at Telegram. It's still strange, because Telegram reconnect every second with the little circle animation. Manually proxy settings in Telegram doesn't work.

RafaelLinux commented 2 years ago

Ver 3.3 beta In my case, as I wrote, none of them (system or Telegram proxy settings) works. The only difference is that with "Use system proxy" seems to connect to some place, cause shows "available (ping: 118ms)", but however, result is same as with Telegram proxy setting: No contacts, no messages but NOT "reconnecting" message neither.

RafaelLinux commented 2 years ago

Version 3.3.0 under Linux KDE

With debug on this message appears all the time, if the proxy settings is on system settings Configuration extension is: 20kde_config_extension Ignored list is: Config is: wpad:// Trying to find the PAC using WPAD... WPAD search via: 24dns_alias_wpad_extension PAC found! Unable to find a required pacrunner!

Connection still not working

If I use the same proxy over "Use custom proxy" it also not working without any debug messages.

Exactly same messages that you put, when using "System settings". In fact I AM USING a PAC file , don't know if you too.

My output executing _PX_DEBUG=1 ./Telegram with "Use system proxy settings" option:

[ALSOFT] (EE) Failed to set real-time priority for thread: Operación no permitida (1)
error: : cannot open
error: : cannot open
error: : cannot open
Configuration extension is: 20kde_config_extension
Ignored list is: 
Config is: 
        pac+file:///home/rafael/proxy_PAC_configuracion.pac
PAC received!
Unable to find a required pacrunner!
Configuration extension is: 20kde_config_extension
Ignored list is: 
Config is: 
        pac+file:///home/rafael/proxy_PAC_configuracion.pac
Unable to find a required pacrunner!
Configuration extension is: 20kde_config_extension
Ignored list is: 
(repetedly same message)
ilya-fedin commented 2 years ago

My output executing _PX_DEBUG=1 ./Telegram with "Use system proxy settings" option:

It seems your system settings are set to get proxy parameters from a PAC (JS) script at URL, tdesktop doesn't support that (or it would need to have a JS engine), you have to specify the proxy manually in your system settings

GUO-CAI commented 2 years ago

好的谢谢

---Original--- From: @.> Date: Thu, Dec 9, 2021 15:01 PM To: @.>; Cc: @.***>; Subject: Re: [telegramdesktop/tdesktop] Proxy reconnect forever after updating TODAY to 3.2.6 beta (Issue #17316)

My output executing _PX_DEBUG=1 ./Telegram with "Use system proxy settings" option:

It seems your system settings are set to get proxy parameters from a PAC (JS) script at URL, tdesktop doesn't support that (or it would need to have a JS engine), you have to specify the proxy manually in your system settings

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

GUO-CAI commented 2 years ago

我的电脑CP被锁住了。

---Original--- From: "Rafael Linux @.> Date: Thu, Dec 9, 2021 14:49 PM To: @.>; Cc: @.***>; Subject: Re: [telegramdesktop/tdesktop] Proxy reconnect forever after updating TODAY to 3.2.6 beta (Issue #17316)

Ver 3.3 beta In my case, as I wrote, none of them (system or Telegram proxy settings) works. The only difference is that with "Use system proxy" seems to connect to some place, cause shows "available (ping: 118ms)", but however, result is same as with Telegram proxy setting: No contacts, no messages but NOT "reconnecting" message neither.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

proofy commented 2 years ago

Have a look at https://github.com/telegramdesktop/tdesktop/blob/b890b9542cb70676a7bd41db03412b2e8e921d67/Telegram/SourceFiles/core/sandbox.cpp#L482

I'm not deep enough to understand this, but it seems that there are three types of proxy settings. Build-In Proxy setting, a ProxyFactory from the operation system, that never else is used and NoProxy. The use of !Core::IsAppLaunched() is confusing me too.

ilya-fedin commented 2 years ago

ProxyFactory from the operation system, that never else is used

What do you mean? It's used when tdesktop is configured to use sysetm proxy (i.e. by default)

The use of !Core::IsAppLaunched() is confusing me too.

tdesktop has crash handler, it's launched before entire app is launched and it should use a simplified proxyfying code without a chance to crash.

valia0906 commented 2 years ago

I have the same problem on ubuntu 20.04 and fresh installed telegram 3.3.0 from official web-site. Custom HTTP proxy setting reconnects infinitely. Previous version which I used worked fine (3.2.4).

SysMan-One commented 2 years ago

Windows version - the same problem.

proofy commented 2 years ago

Is there a test phone number, so i can use a GUI Test program to show you what happens?

proofy commented 2 years ago

New installation with flatpak. Newest version 3.4.2. More problems. My workaround doesn't work anymore.

ilya-fedin commented 2 years ago

Workaround? It's first time you mention a workaround

proofy commented 2 years ago

Workaround? It's first time you mention a workaround

https://github.com/telegramdesktop/tdesktop/issues/17316#issuecomment-989333805

RafaelLinux commented 2 years ago

Workaround? It's first time you mention a workaround

#17316 (comment)

I haven't been able to test your workaround, as I don't use the Flatpak version, but I'm sure that doesn't change the problem of it not working after the update. Also, I think in your case you don't require authentication with the proxy.

ilya-fedin commented 2 years ago

as I don't use the Flatpak version

How system settings are related to flatpak?

RafaelLinux commented 2 years ago

Today, january third, Telegram Desktop updated two times (3.3.2 and 3.4.2) but this bug still not fixed. It's very curious that (as I wrote in https://github.com/telegramdesktop/tdesktop/issues/17316#issuecomment-985311534 previous post) Telegram Desktop gets to connect to Internet for updates, but for nothing more!!!!

My output executing _PX_DEBUG=1 ./Telegram with "Use system proxy settings" option:

It seems your system settings are set to get proxy parameters from a PAC (JS) script at URL, tdesktop doesn't support that (or it would need to have a JS engine), you have to specify the proxy manually in your system settings

Remember my Telegram proxy settings was not changed before TD update, so using or not a PAC file makes not difference in my case. It was working. But anyway, thanks for warn me about that fact!!!

ilya-fedin commented 2 years ago

It was working.

The key word is was. This is going to be a long standing issue, so you need to play with settings to find a workaround or Telegram will just not be able to connect, unfortunately.

gets to connect to Internet for updates, but for nothing more!!!!

There's two ways tdesktop can get an update: via http server or via mtproto from Telegram servers. So it can work even when you can't connect to Telegram itself.

ilya-fedin commented 2 years ago

The best variant is to set proxy with "Use system proxy configuration" in KDE settings (it sets the proxy with a simple HTTP_PROXY environment variable, as opposed to "Use manually specified proxy configuration" that sets proxy in KDE configs for KDE applications)

RafaelLinux commented 2 years ago

It was working.

The key word is was. This is going to be a long standing issue, so you need to play with settings to find a workaround or Telegram will just not be able to connect, unfortunately.

I have already tried all possible changes to the local configuration on my PC. Unfortunately, I can't do anything about the use of the proxy. It is mandatory in my case to use a proxy with authentication. Due to the complexity of our intranet, I have been solving Internet access problems with other applications in different ways, such as using a PAC file. Unfortunately, KDE Plasma has some problems with the proxy issue, so thanks to a previous comment of yours about it, I will try as soon as I can to test what happens if I use GNOME instead of KDE Plasma and I will comment here.

gets to connect to Internet for updates, but for nothing more!!!!

There's two ways tdesktop can get an update: via http server or via mtproto from Telegram servers. So it can work even when you can't connect to Telegram itself.

Thank you for clarifying why this is happening. I thought it might be interesting to comment on that curiosity in case it gave any clues as to how to solve the problem ;)

RafaelLinux commented 2 years ago

Someone with this bug NOT using KDE Plasma as desktop?

proofy commented 2 years ago

I switch to Flatpak, because Flatpak is using OpenDesktop. So I thought it could be a workaround. But it doesn't work. I also use Flatseal to config environment in many ways.. I haven't found a solution.