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

Java - simultaneous Client #2707

Closed jojo27888 closed 11 months ago

jojo27888 commented 11 months ago

Hello,

I use TDLib in a Spring Boot api. Sometimes, the app manage requests from different Telegram account so I create one Client for each account (with separated databaseDirectory). Each request is runned in separete thread. All works fine except when one of these Client (that I will call client1 bellow) is in AuthorizationStateWaitCode or AuthorizationStateWaitPassword. In that case, for all other Client, I don't receive any answer when a I send a command (client.send) as long as I don't send a code or password for client1. It looks like these Client are waiting that client1 pass in client1 send(new TdApi.CheckAuthenticationCode(authCode), new AuthorizationRequestHandler()); or client1 .send(new TdApi.CheckAuthenticationPassword(authPasswd), new AuthorizationRequestHandler()); After sending code or password, all other Client receive answer to her send command. This "problem" is after reapeating as long as client1 is not in state differend as AuthorizationStateWaitCode or AuthorizationStateWaitPassword.

Is it normal or did I something wrong ? I see some similar issues that speak about ClientManager but this classe is not implemented in Java example. I have to implement them by myself ?

Best Regards

levlam commented 11 months ago

Updates and responses for all clients are processed in the same thread. The code for authorization update handling blocks the thread and makes impossible to process other responses. You need to make processing of the authorization states asynchronous or to move it to another thread.

jojo27888 commented 11 months ago

@levlam Ok, thanks for your quick answer :-)