Telegram-FOSS-Team / Telegram-FOSS

Unofficial, FOSS-friendly fork of the original Telegram client for Android
GNU General Public License v2.0
2.78k stars 361 forks source link

Unreliable Message Delivery since 3.1.3 #36

Closed vanitasvitae closed 8 years ago

vanitasvitae commented 8 years ago

Hi Since the latest update, push messages are wa, less reliable than in earlier versions. I didnt change any settings. Often messages dont appear even when I have the chat open. When Im in a group chat, i often get multiple messages at once delivered.

Im using Paranoid Android 5.1

vanitasvitae commented 8 years ago

*way less reliable

Bubu commented 8 years ago

I had the same Problem. Reinstalling Telegram seems to have fixed this. But it does reappear when going back one Version to 3.1.2 through fdroid and upgrading from there to 3.1.3 again.

Bubu commented 8 years ago

It seems to happen sometimes in the emulator. I can't reliably reproduce it. And when it did happen there were no suspicious logcat messages. I have no idea how to debug this.

vanitasvitae commented 8 years ago

Is there a way to provide you with logs?

ghost commented 8 years ago

I have this same issue and also seemed to be fixed by reinstalling the app, but it's there again. I also know the official Telegram team has a modified telegram client with log support. I don't know if its code is avaible tho

geileszeuch commented 8 years ago

I noticed this problem heavily since 3.2.2. Sometimes I receive messages heavily delayed in the middle of the night. The strange thing is that although I confirmed that the messages were sent during the day, the timestamp under the message might show (not always) that it was sent at night. Sometimes messages only appear when I open telegram and at other times I don't receive them although the chat is open. Also, it happens that my messages are not being received or with huge delay although they have 1 checkmark and are being sent to the official Telegram upstream version. There needs to be a better way of fixing this than reinstalling. Some people have secret chats that they don't want to be deleted, which, I assume, happens when reinstalling.

Bubu commented 8 years ago

Yes, I agree that reinstalling is not a good solution to the Problem. Could someone maybe try out if clearing the app's cache (should not delete secret chats) and/or data (this again clears secret chats) also solves this problem?

vanitasvitae commented 8 years ago

Clearing cache doesn't help. Still delayed messages.

vanitasvitae commented 8 years ago

Trying with deleted data right now.

ghost commented 8 years ago

Actually in my case it's not just delayed messages but also sound notification sounds a bit later than vibration. They're not simultaneous has used to be.

El 5 de octubre de 2015 12:59:27 CEST, vanitasvitae notifications@github.com escribió:

Trying with deleted data right now.


Reply to this email directly or view it on GitHub: https://github.com/slp/Telegram-FOSS/issues/36#issuecomment-145495253

Ecron commented 8 years ago

@helfio said:

I have this same issue and also seemed to be fixed by reinstalling the app, but it's there again. I also know the official Telegram team has a modified telegram client with log support. I don't know if its code is avaible tho

Not in the official Android app afaik. They included a debug option in iOS app, pressing several times over Telegram's icon in the "Change number" screen, but there's no option in official Android app. Although I know for sure they will implement it in the future.

It would be a good idea to implement some hidden debug options here in the meanwhile to be able to find out what's the problem with the messages delivery...

slp commented 8 years ago

Late Telegram versions had introduced a lot of changes in the way it manages the connections to its Datacenters. Version 3.2.2 even moved a lot of Java code to a JNI library (I suppose to share the code with other platforms).

On the other hand, old Telegram versions relied a lot on GCM (Google Cloud Messaging) for receiving notifications, which forced me to implement a Background Service class to pool the servers at regular times. At some point, upstream implemented a push based solution to replace GCM, and made it the preferred way to receive notifications, but with the last two versions it seems that we're back there again.

I think I'll be able to provide an experimental APK with a Background Service in a few days. I'll need some people to test it, to confirm that notifications are received with a reasonable delay, even when the phone has been asleep for hours, and that the impact on battery life is not too harsh.

ghost commented 8 years ago

I can test it. I don't know if you could make the apk with different system name (no org.telegram.messenger) so we don't have to uninstall the standard FOSS :)

Ecron commented 8 years ago

Count on me for the testing too.

geileszeuch commented 8 years ago

@slp You're saying that they're degrading their own push service although telegram is configured by default to use it? That sounds very unlikely and if true very stupid. It seems like people on the official client are not complaining about delayed messages, at least I can't notice it on their twitter channel. Is it possible that the replacement of boringssl is somehow involved and caused issues?

What about the last three commits on upstream which were made after the 3.2.2 release tag: -"Using pipe instead of signal to interrupt epoll_wait" -"Fixed restore key generation after network becomes available" -"Fixed release and debug AndroidManifest.xml"

Do they maybe fix our problem? Judging by DrKlos actions on github, I can very well imagine that they were released in the store just not tagged with a new release.

Also, how then to explain the fact that search doesn't work anymore. I cannot imagine that it doesn't work on upstream and remained unnoticed for weeks now. There are no complains on twitter. Plus not only are the messages delayed, but also the vibration and notification sound appear only a few seconds after the phone starts to flash the notification light.

I just hope that something accidently went wrong when merging upstream so we don't need to go back to a background service. Keep up the good work slp.

(Side note: doze on android m might require some changes to get push messages without gcm done, but android m support was only released after 3.2.2.)

Ecron commented 8 years ago

The upstream official app has none of these problems. It gets the messages and notifications in time, and the search is active. Nobody reported any of those issues.

I can't imagine what's the reason :confused:

mikran commented 8 years ago

I changed notification ringtone to 'none' and vibration to 'short' and all notifications dissappeared / are late. I then readded a sound notification and now it seems to work again. And this was about the first thing I did after reinstall.

edit: and messages are delayed again, that didn't fix it as was the case with re-install.

xavihernandez commented 8 years ago

Same here, it's like IDLE connection is not kept. When I open the application I can read "Waiting for network..." (in EDGE I can see this message as connection is slower and then takes more time to connect) before it shows "Telegram"

xavihernandez commented 8 years ago

@slp hi, any news on this?

Bubu commented 8 years ago

This problem did not occur with the latest update for me. Does v3.2.6 fix this for everyone?

ghost commented 8 years ago

I suffered this issue and I've just updated a few hours ago. It looks like it's not fixed but I want to test it longer before confirm anything.

slp commented 8 years ago

@helfio Please check in Settings->Apps->Running->Telegram if the "NotificationsService" is present and running.

ghost commented 8 years ago

It's present and running. It shows the same time the app have been opened.

slp commented 8 years ago

@helfio I've just built a package compiled with DEBUG_VERSION=true, which enables the logcat output. You can download it from here: https://sinrega.mooo.com/index.php/s/cTMqwYXLs5Q1rFs

You can use it to obtain some debug info, but as it's signed with a different certificate, you'll need to uninstall the FDroid version, losing your secret chats and preferences in the process.

ghost commented 8 years ago

Definitely the issue it's not solved on my phone. It doesn't get notifications of messages I already read from telegram desktop neither.

I'm going to use this package to try obtain some info. This debug flag just enable output to system logcat, right?

Edit: this flag enabled the log system of telegram, just as the upstream team does to get info about issues. Just as I mentioned here: https://github.com/slp/Telegram-FOSS/issues/36#issuecomment-145253187

Bubu commented 8 years ago

You said earlier, you solved this by reinstalling the app but then the problem reappeared? Was that after another update or without any apparent cause?

If it was after updating again you should be able to fix it again with reinstalling. And at least for me the problem did not appear with the latest update (but that might have been luck...).

ghost commented 8 years ago

@Bubu It was after uninstall and install again I think, but I cannot remember.

I just made a test with debug version and indeed the issue it's still there. This is the Telegram log: (I have a copy of this)

I sent a message at 23:23:02 and switched on the screen at 23:28. Before opened Telegram I checked the notification service was running wich it was, then opened the app and then the notification arrived.

I hope this helps to catch the error.

Edit: same result on mobile data instead of WiFi. Message sent at 00:10, Screen on at 00:18~19, check for notification service (running), open the app and then the notification arrives. Here is the log: (I have a copy of this) 17_11_2015_23_10_35(1).txt

vanitasvitae commented 8 years ago

I can confirm that message delivery is still unreliable :/ Message arrives not until telegram is opened.

Bubu commented 8 years ago

I have another report for delivery again not working after the update. Fixed again with reinstalling. @slp: Any idea why this might happen?

ghost commented 8 years ago

@bubu what version did you have? What version does the trick? I'm running debug version which has this issue.

Bubu commented 8 years ago

Not me; but updating from 3.2.2 to 3.2.6 broke it. Uninstalling 3.26 and reinstalling again fixed it.

ghost commented 8 years ago

I reinstalled a few days ago and still not working.

FLOSS version from F-Droid.

BTW I'm in Moto G Falcon (2013) running CM12.1 a nightly from a couple of days ago. Previously it had an older nightly. I don't know if this makes any difference.

El 23 de noviembre de 2015 9:05:54 CET, Marcus Hoffmann notifications@github.com escribió:

Not me; but updating from 3.2.2 to 3.2.6 broke it. Uninstalling 3.26 and reinstalling again fixed it.


Reply to this email directly or view it on GitHub: https://github.com/slp/Telegram-FOSS/issues/36#issuecomment-158873376

xavihernandez commented 8 years ago

Just for info, I repeat that when I'm in EDGE (and then connection is slower I can see written "Waiting for network..." "Connecting..." and "Updating..." message. Seems to prove that connection is lost when application is in background. This is still present in v3.2.6.

tmelikoff commented 8 years ago

I have recently reinstalled my android device and not able anymore to install 3.1.2 from f-droid. Is there any way to find the 3.1.2 apk ( org.telegram.messenger_586.apk ) ?

Akronix commented 8 years ago

@tmelikoff I think this issue is not about that, please open a new specific one. Anyway, why do you want an out-of-date version??

tmelikoff commented 8 years ago

@Akronix you are correct about opening a specific issue but my request is more related to this one. It's not really an issue tho. I reckon the unreliable message delivery as in per this issue subject. I need an outdated version because message delivery is unreliable in versions > 3.1.2

vanitasvitae commented 8 years ago

@tmelikoff Have you tried to check fdroid archive repo in FDroid?

slp commented 8 years ago

@helfio Thanks for your logs.

Looking at them, I'm starting to think that this issue, among others that for some are solved after reinstalling/upgrading, is related to a configuration file disguised as a data file that Telegram creates. Said file, depending on its location, will or will not be removed when uninstalling the app.

Could you please look for a file (using adb or some app) on your phone named "tgnet.dat"? If you find it, uninstall Telegram-FOSS, remove all occurrences of that file, and reinstall it.

I think this could help fixing most of the problems that appeared on the last few releases.

ghost commented 8 years ago

@slp Thank you for your work :)

I've found the file on /data/data/org.telegram.messenger/files/tgnet.dat I'm going to proceed as you say and I'll report in a few hours after some testing. Stay tuned!

Bubu commented 8 years ago

Is this a problem unique to the fdroid version or could this happen with the upstream version too?

ghost commented 8 years ago

Well, just uninstalled and the folder /data/data/org.telegram.messenger it's gone.

xavihernandez commented 8 years ago

@helfio Hi, could you tell me if it has fixed the undelivered messages until application is opened ?

TIA

@slp thanks for your workaround

ghost commented 8 years ago

@xavihernandez It's not fixed.

xavihernandez commented 8 years ago

@helfio thanks for your feedback!!

Bubu commented 8 years ago

@slp While merging the lastest upstream version I just noticed the BUILD_VERSION constant (here) was not updated since 3.1.2. And it is referenced in some user config clearing code and the connection init code. Might that be the root cause?

ghost commented 8 years ago

In spite of I don't know about coding java nor android, I think it worth a try. I can test it if @slp compiles a testing build :)

slp commented 8 years ago

@Bubu Good catch! That could be the root cause, but in that case, removing tgnet.dat should fix the problem.

@helfio I've just uploaded a version with Marcus' changes: https://sinrega.mooo.com/index.php/s/zE82BXl136WykZ3

ghost commented 8 years ago

@slp testing!

ghost commented 8 years ago

Still not working :(

slp commented 8 years ago

@helfio OK, it's time for some serious debugging ;-)

I've just built another apk, this time with debugging options for JNI based tgnet enabled too. This way, it'll generate a *_net.txt logfile, which will show us what is really happening with your connection when the app goes to background.

Please give it a try: https://sinrega.mooo.com/index.php/s/Z5FtGrb87owsjpa