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

AuthorizationStateLoggingOut never finishes (tdlib v1.8.20, java) #2665

Closed baikatov closed 11 months ago

baikatov commented 12 months ago

AuthorizationStateLoggingOut never finishes (tdlib v1.8.20, java)

Steps to reproduce (both in test dc and prod)

  1. Launch Example.java
  2. Log in using phone and code, eg 9996623336 and 22222
  3. Log out by typing lo

"Logging out" is printed to the console, followed by "Ok { }" after a few seconds indicating it has been completed successfully.

I see in my telegram application, that this session is correctly removed after TdApi.LogOut(), so it works, at least partially.

But then application just hangs.

Javadoc for LogOut says it should end up closing client, deleting local data and triggering authorizationStateClosed after some time, but it doesn't.

Any subsequent restarts of the Example.java end up hanging with the same message "Logging out" as well, due to tdlib catching AuthorizationStateLoggingOut event on application start-up. Only this time it isn't followed by "Ok { }".

The only way I managed to fix this is to:

  1. After calling TdApi.LogOut(), wait until TdApi.LogOut() callback finishes
  2. Call TdApi.Close() and wait until it's callback finishes
  3. Delete entire databaseDirectory
  4. Recreate client using Client.create()
  5. Now it's possible to login using another phone number and continue work

Seems hacky, and the documentation says it should be done automatically.

Is this solution suitable for production?


Running in ubuntu 22.04 under WSL2 Eclipse Temurin JDK 21 Logs from test dc and log verbosity level 4: tdlib.log

levlam commented 11 months ago

Thank you for the report. The issue has been fixed in master.

baikatov commented 11 months ago

Everything works, thanks!