tdlib / td

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

Error : 500 : auth.logOut returned false! #402

Closed ztdan4ik closed 6 years ago

ztdan4ik commented 6 years ago

Hi all!

I'm working with tdlib in php env. I have a problem with auth.logOut

What i'm doing

$parameters = new Parameters();
$parameters->setParameter('use_test_dc',true);
$parameters->setParameter('api_id','ххх');
$parameters->setParameter('api_hash','ххх');
$client = new Client();
$client->setTdlibParameters($parameters);
$client->setDatabaseEncryptionKey();
// Here authorizationStateReady
$client->send('logOut'); // td_json_client_send($this->client, ['@type' => 'logOut']);

while (true) {
    echo $client->receive(); // td_json_client_receive($this->client, 5)
}

And after that I got an error Responses

{"@type":"updateAuthorizationState","authorization_state":{"@type":"authorizationStateReady"}}
{"@type":"ok"}
{"@type":"updateAuthorizationState","authorization_state":{"@type":"authorizationStateLoggingOut"}}
{"@type":"updateScopeNotificationSettings","scope":{"@type":"notificationSettingsScopePrivateChats"},"notification_settings":{"@type":"scopeNotificationSettings","mute_for":0,"sound":"default","show_preview":true}}
{"@type":"updateScopeNotificationSettings","scope":{"@type":"notificationSettingsScopeGroupChats"},"notification_settings":{"@type":"scopeNotificationSettings","mute_for":0,"sound":"default","show_preview":true}}
{"@type":"updateConnectionState","state":{"@type":"connectionStateConnecting"}}
{"@type":"updateConnectionState","state":{"@type":"connectionStateUpdating"}}
{"@type":"updateConnectionState","state":{"@type":"connectionStateConnecting"}}

And then errors

[ 1][t 1][1541612583.264759064][AuthManager.cpp:837][!AuthManager][&status.is_error()]  auth.logOut failed: [Error : 500 : auth.logOut returned false!]
[ 1][t 1][1541612583.265763998][UpdatesManager.cpp:146][!Td]    updates.getDifference error: [Error : 401 : AUTH_KEY_UNREGISTERED]

Again responses

{"@type":"ok"}
{"@type":"updateAuthorizationState","authorization_state":{"@type":"authorizationStateClosing"}}
{"@type":"updateOption","name":"calls_enabled","value":{"@type":"optionValueEmpty"}}
{"@type":"updateOption","name":"basic_group_size_max","value":{"@type":"optionValueEmpty"}}
{"@type":"updateOption","name":"test_mode","value":{"@type":"optionValueEmpty"}}
{"@type":"updateOption","name":"t_me_url","value":{"@type":"optionValueEmpty"}}
{"@type":"updateOption","name":"forwarded_message_count_max","value":{"@type":"optionValueEmpty"}}
{"@type":"updateOption","name":"pinned_chat_count_max","value":{"@type":"optionValueEmpty"}}
{"@type":"updateOption","name":"photo_search_bot_username","value":{"@type":"optionValueEmpty"}}
{"@type":"updateOption","name":"call_packet_timeout_ms","value":{"@type":"optionValueEmpty"}}
{"@type":"updateOption","name":"call_connect_timeout_ms","value":{"@type":"optionValueEmpty"}}
{"@type":"updateOption","name":"my_id","value":{"@type":"optionValueEmpty"}}
{"@type":"updateOption","name":"animation_search_bot_username","value":{"@type":"optionValueEmpty"}}
{"@type":"updateOption","name":"venue_search_bot_username","value":{"@type":"optionValueEmpty"}}
{"@type":"updateOption","name":"supergroup_size_max","value":{"@type":"optionValueEmpty"}}
{"@type":"updateOption","name":"message_caption_length_max","value":{"@type":"optionValueEmpty"}}
{"@type":"updateOption","name":"authorization_date","value":{"@type":"optionValueEmpty"}}
{"@type":"updateOption","name":"message_text_length_max","value":{"@type":"optionValueEmpty"}}
{"@type":"updateOption","name":"favorite_stickers_limit","value":{"@type":"optionValueEmpty"}}
{"@type":"updateAuthorizationState","authorization_state":{"@type":"authorizationStateClosed"}}

Looks like it has logged out. But what is the problem with error?

Many thanks for your time.

levlam commented 6 years ago

In fact, this error can be ignored and has no bad consequnces. The client was successfully logged out, but server has returned error for the corresponding request. It is just a remainder for us that server behavior on logging out can be improved.

Error in updates.getDifference is also expected, so I will just silence it.

ztdan4ik commented 6 years ago

Oh... Ok, thanks! Now I can be quiet about this.

And one more question: As you see I'm using test dc env for developing application. Now, when I'm trying login with already registered account I always getting a code type "authenticationCodeTypeTelegramMessage" even tho I don't have authorized clients at this time. I feel like some Client instances before I didn't logout properly and just shut it down... Can be problem with this? How can I logout from all devices? I did't find any methods for this option.

Thanks again.

levlam commented 6 years ago

You can get list of active sessions through getActiveSessions method one day after a successful authorization and terminate them through terminateSession. Or you can just call terminateAllOtherSessions (you will still need to wait a day for security purposes).

ztdan4ik commented 6 years ago

Thanks for your time! Great job!