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

because Flatpak is using OpenDesktop

What's OpenDesktop?

proofy commented 2 years ago

because Flatpak is using OpenDesktop

What's OpenDesktop?

sorry, freedesktop.

` $>flatpak info org.telegram.desktop

Telegram Desktop - Fast. Secure. Powerful.

     Kennung: org.telegram.desktop
         Ref: app/org.telegram.desktop/x86_64/stable
 Architektur: x86_64
       Zweig: stable
     Version: 3.4.2
     License: GPL-3.0
    Ursprung: flathub
    Sammlung: org.flathub.Stable
Installation: system
 Installiert: 145,5 MB
Laufzeitumgebung: org.freedesktop.Platform/x86_64/21.08
         Sdk: org.freedesktop.Sdk/x86_64/21.08

      Commit: 45977570427e792ae027fad41f5a072628140fc5cc2d06099acfd6c638b62ec8
      Parent: c342cf53eb4b435173cae0f2c01099ce1be47b85b5e676190c24d1ff30bd39f3
     Subject: Update tdesktop.git to 3.4.2 (e9adad97)
        Date: 2021-12-31 23:30:45 +0000

`

ilya-fedin commented 2 years ago

It's just runtime name

proofy commented 2 years ago

Next workaround: I have installed tinyproxy on my pc and configure the "normal" squid proxy as default upstream. Than I add this tiniyproxy (127.0.0.0:8888) in Telegram (flatpak version) and use this. It works. So, it could be a special problem with or from squid?

ilya-fedin commented 2 years ago

Maybe, who knows. Maybe Qt's and squid's proxy implementations became incompatible.

amozzhuhin commented 2 years ago

I have done some digging and found possible reason - https://codereview.qt-project.org/c/qt/qtbase/+/389299.

ilya-fedin commented 2 years ago

@amozzhuhin it seems 6.2.3 is branched off already and you forgot to add it to Pick-to

amozzhuhin commented 2 years ago

Hm, my patch was merged in dev with Pick-to: 6.3 6.2 5.15. Today it was automatically cherry-picked to 6.2 - https://codereview.qt-project.org/c/qt%2Fqtbase/+/389801. I think we need wait some time before it will be merged.

ilya-fedin commented 2 years ago

6.2.3 is a separate branch. See how it should look like: https://codereview.qt-project.org/c/qt/qtbase/+/389459

Pick-to: 6.3 6.2 6.2.3

ilya-fedin commented 2 years ago

In the current state your patch will be only in 6.2.4.

ilya-fedin commented 2 years ago

I think you can create a manual cherry-pick while it's not that late

amozzhuhin commented 2 years ago

Sorry, this is my first patch in Qt. I don't fully understand they processes. But in your link is see Failed to cherry pick to 6.2.3 message and I don't see any commits in dev branch with patch number in Pick-to. I miss something?

ilya-fedin commented 2 years ago

Such commits are rare because branches with patch numbers are created multiple days before the tag (v6.2.3 tag is planned at January 18 according to their wiki), so you can't just find them in dev branch looking at last commits :) But you can do like that: https://codereview.qt-project.org/q/pick-to+6.2.3

But in your link is see Failed to cherry pick to 6.2.3 message

Seem to be a bug in their automatic https://codereview.qt-project.org/c/qt/qtbase/+/389601/2#message-9bdbb1469e78a3091fd3c641bd95fbebf0f76002

ilya-fedin commented 2 years ago

I believe you can do like that

git checkout 6.2.3
git checkout -b some-branch-name
git cherry-pick -x 66f0149693c810a512001d9d4df89b6f9d7a9327
git push gerrit HEAD:refs/for/6.2.3
amozzhuhin commented 2 years ago

Done - https://codereview.qt-project.org/c/qt/qtbase/+/389992.

ilya-fedin commented 2 years ago

Now you need to stage ;)

john-preston commented 2 years ago

I can cherry-pick something to the next beta / stable release (by a Qt patch), if there is definite knowledge of something fixing this issue.

amozzhuhin commented 2 years ago

I'm not sure if my changes fix problem of the this issue reporter. But I have problem with proxy too and it is very similar - Telegram stopped working through a proxy server after upgrading to version 3.2.6.

In my case, Telegram connects to a proxy server and makes several POST requests to some IP address. After that, it opens a new connection to the proxy server and sends a CONNECT request to the proxy server itself. The proxy server rejects the request, which is interpreted by Telegram as a connection error. This behavour is exactly the same as described in https://github.com/telegramdesktop/tdesktop/issues/17316#issuecomment-984407607 .

The worst thing is that my fixes solve a problem that depends on timings and may not be reproduced sometimes. When the network is running fast, all requests within the QHttpNetworkConnection are sent via a single connection for which the proxy server settings are set. But if the first connection is busy, then QHttpNetworkConnection opens a new one for which the proxy server settings are not set. But Telegram also sets global proxy settings for the application, which leads to its use for TCP sockets. As a result, QHttpNetworkConnection takes the settings from the first connection and tries to connect to the proxy in a TCP connection that already works through the same proxy.

Now you need to stage ;)

I don't have enough permissions yet. :(

ilya-fedin commented 2 years ago

I don't have enough permissions yet. :(

Interesting... Maybe you should ask the reviewer to stage it?

ilya-fedin commented 2 years ago

Ah, looks like the reviewer already added someone else to the reviewers and asked

ilya-fedin commented 2 years ago

Looks like the 6.2 cherry-pick failed to stage, so it's only in 6.3 and dev now :(

amozzhuhin commented 2 years ago

I have a patched version of Telegram. And this is currently solution for me. But if this problem affects several users, then maybe my changes can be temporary included in desktop-app/patches until they will be included in Qt release?

Aokromes commented 2 years ago

I have a patched version of Telegram. And this is currently solution for me. But if this problem affects several users, then maybe my changes can be temporary included in desktop-app/patches until they will be included in Qt release?

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

john-preston commented 2 years ago

@amozzhuhin Yes, np, let's test that. What is the patch that I should apply? Or you can just PR it to desktop-app/patches and link the PR here.

jaghili commented 2 years ago

I am facing the same issue with version 3.4.3-2 on Arch. I tried to change proxy settings but no changes.

I downgraded to 3.4.0-1 and now it works fine. Hope this will be fixed soon.

RafaelLinux commented 2 years ago

I am facing the same issue with version 3.4.3-2 on Arch. I tried to change proxy settings but no changes.

I downgraded to 3.4.0-1 and now it works fine. Hope this will be fixed soon.

Thank you jaghili!!! Reading your message, I decided to reinstall a version prior to the one from which (3.2.6) the problems with the proxy started. Then, I noticed the following (all this, on the same PC where Telegram Desktop is NO longer able to connect through the proxy): Since version 3.2.0 (3.2.4, 3.2.5 ... ) TD is not able to use the configured proxy, which surprised me, cause it was working JUST till I updated to 3.2.6 (and I was updating to each new version previously). Moreover, TD is not able to display the QR code (because it is not able to connect even if the proxy is configured).

Up to version 3.1.0 (I haven't tested 3.1.x) TD WORKS, even showing the QR code to log in.

If you need more information, I can test with other versions on request. So, I guess the problem is still with TD, and not with Plasma as I had started to think ....

amozzhuhin commented 2 years ago

@john-preston, thank you, I will wait until tomorrow for the decision of the Qt developers about integration of my patch into 6.2.3. If it is rejected, I will do PR with it into the desktop-app/patches.

ilya-fedin commented 2 years ago

So, I guess the problem is still with TD, and not with Plasma as I had started to think ....

The problem is in Qt. Qt was updated in version 3.1.10 and this should be the first bad version.

RafaelLinux commented 2 years ago

I have been using the KDE Plasma desktop for many years since before it was called "Plasma", and indeed, its handling of proxy connections is very irregular. In fact, I've had an open issue about it for a while now, but apparently it's "not a priority" for the KDE developers. It must be more important to add new features than to have a stable and really working base first.

Therefore, I wouldn't be surprised if, as you say, it coincided in time with a KDE update that I had done in the days before the Telegram Desktop update.

However, and as I indicate in the title of the header, how is it possible that it has been working with TD 3.2.x until the TD 3.2.6 update? And what's more, why now I try to work with versions up to 3.2.6 (as it was working) and only the versions below or equal to TD 3.1.0 work with the proxy? This is very strange and leaves a big question mark as to what extent the changes have been made in TD 3.2.6.

For the time being, I have no choice but to use TD 3.1.0 for as long as I can with the limitations it entails, until the problem is solved.

ilya-fedin commented 2 years ago

Therefore, I wouldn't be surprised if, as you say, it coincided in time with a KDE update that I had done in the days before the Telegram Desktop update.

I said that the bug in Qt, it's not in KDE. Qt != KDE. And, moreover, Qt is bundled to the static Telegram binary and is upgraded/downgraded with Telegram itself.

ilya-fedin commented 2 years ago

And what's more, why now I try to work with versions up to 3.2.6 (as it was working) and only the versions below or equal to TD 3.1.0 work with the proxy?

I explained that right before your message, in https://github.com/telegramdesktop/tdesktop/issues/17316#issuecomment-1014781840

RafaelLinux commented 2 years ago

My mistake. I didn't understand that, as you explain, the Qt libraries that TD uses are not those of the system where it is used.

Still, it remains a mystery to me why I can no longer use TD version 3.2.5, which before upgrading to TD 3.2.6 worked with the proxy without any problems.

Thank you for your answers!

ilya-fedin commented 2 years ago

Still, it remains a mystery to me why I can no longer use TD version 3.2.5

Well, in the first post you saying "It was just working fine JUST after update it, but now it doesn't work", so apparently it can sometimes work, maybe it's a kind of race condition in Qt

RafaelLinux commented 2 years ago

Well, in the first post you saying "It was just working fine JUST after update it, but now it doesn't work", so apparently it can sometimes work, maybe it's a kind of race condition in Qt

Maybe I've explained myself badly, so I'll summarise. There have been two proxy-related issues since I've been using TD (on Linux)

As a side note, in case it might be interesting: Everything, including web browsers, needs to use a proxy in our network. When I access https://web.telegram.org/z/ with a web browser, the website is unable to display the QR code and stays forever in a loop showing a spinning ring. On the other hand, when I access https://web.telegram.org/k/ it does manage to display the QR code. Maybe it is not related to the TD version, but the same happens with TD 3.1.0, which DOES display the QR code, but versions after TD 3.1.0 DO NOT display the QR code.

ilya-fedin commented 2 years ago
  • All the previous versions to those mentioned above worked, including 3.2.5. It is precisely after installing version 3.2.6 when it is impossible to connect through the proxy.

According to:

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

It was working with 3.2.6 for you initially. But then stopped. So that could be not always reproducible. I think the bug is present since 3.1.10, when Qt was updated.

RafaelLinux commented 2 years ago

More simple:

TD from 2.x to 2.7.5 --> All worked TD from 2.7.5 to 3.X (undetermined) --> Not working TD from 3.1.0 to 3.2.5 --> All worked. WORKING WITH PROXY till I installed 3.2.6 TD from 3.2.6 to 3.4.3 --> Not working

So I uninstalled latest version and installed again 3.2.5 ... but NOW it doesn't work.

NOW TD from 3.1.1 to 3.4.3 --> Not working

But since the release of TD 3.2.6, I have performed system upgrades (both operating system and windowing environment). Therefore, I deduce that something else is affecting Telegram Desktop so that versions that previously worked without problems have stopped working for me.

That's all I can say about it, strange as it may seem.

ilya-fedin commented 2 years ago

TD from 3.2.6 to 3.4.3 --> Not working

I don't think you can just say 'not working' since according to your first post it was working:

It was just working fine JUST after update it

So something unrelated to updates happened or the bug is just sporadic. So that means that versions before 3.2.6 (since 3.1.10) were working on coincidence. Or maybe network admins changed something.

RafaelLinux commented 2 years ago

English is not my native language. I mistook "after" for "after". By logic, I meant TD was working just before installing 3.2.6 because, if it wasn't, what would have been the point of opening this thread if it was working since 3.2.6?

NOTE: I just fixed my translation error

ilya-fedin commented 2 years ago

Oh, ok

ilya-fedin commented 2 years ago

This could be tested early on snap edge channel, flathub beta and flathub stable

RafaelLinux commented 2 years ago

I'll wait for binary or AppImage to test.

RafaelLinux commented 2 years ago

Excellent fix. 3.5.1 version works now as always did.

Thank you