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

PHONE_NUMBER_FLOOD - test_dc using #404

Closed ztdan4ik closed 6 years ago

ztdan4ik commented 6 years ago

Hi! I'm using test_dc for developing an application based on tdlib. Now I'm debugging auth process and cannot continue because receiving an error PHONE_NUMBER_FLOOD after sending setAuthenticationPhoneNumber. Is it normal for test env? What is restrictions for this? Can you please provide some informations about this?

levlam commented 6 years ago

Yes. Restrictions in test DC are the same as in production environment for most requests. Otherwise it would be hard to test them and other errors. You can use test phone numbers for testing purposes in test DC.

ztdan4ik commented 6 years ago

Thanks. Test phone numbers it's good. Bad that I didn't find this before creating issue :(

I don't want create new issue, coz it can be not something necessary... Can you please advice me with another errors here?

Now when I running td listener process I'm getting random errors:

[ 0][t 0][1541682888.106995821][Epoll.cpp:25][&epoll_fd == -1]  [PosixError : Too many open files : 24 : epoll_create failed
---------------
[ 1][t110][1541682856.828037739][Binlog.cpp:499][!Td]   [Error : 0 : Too big event [size:875901230]]
[ 1][t110][1541682856.828121185][Binlog.cpp:539][!Td]   Truncate [path:/var/tmp/tdlib_6/td.binlog][old_size:9564][new_size:9044
-----------------
[ 1][t162][1541682143.469781876][Binlog.cpp:499][!Td]   [Error : 0 : crc mismatch [actual:0x5d48c41b][expected:0x00000001]LogEvent[[id:0x000000000000002b][type:17191][flags:1][data:284]][/home/freelance/web/yiishop.de-v.net/public_html/td/tddb/td/db/binlog/Binlog.cpp:139]]
[ 1][t162][1541682143.470920801][Binlog.cpp:539][!Td]   Truncate [path:/var/tmp/tdlib_6/td.binlog][old_size:9636][new_size:7660]

It's appear on different states and almost always aborting the script.

levlam commented 6 years ago

First one is unavoidable crash when too much TDLib Clients was created, and there is not enough system resources to create new Client. You can use sudo ulimit -n to increase number of allowed to open file descriptors. See this question for more details.

Second and third errors means that database was corrupted. In TDLib < 1.4.0 this could happen if a process creates simulteneously a lot of TDLib clients with the same database path, i.e. with the same database. Are you sure that you close all TDLib clients before opening new clients with the same database_path? First error can also be caused by not properly closed unused TDLib instances.

ztdan4ik commented 6 years ago

Are you sure that you close all TDLib clients before opening new clients with the same database_path? I'm not sure... It can be.

How can I close all TDLib clients now?

In TDLib < 1.4.0 this could happen

What is the current version? As I see in https://github.com/tdlib/td/releases latest is 1.3

levlam commented 6 years ago

I'm not sure... It can be. How can I close all TDLib clients now?

It depends on how you created them and which TDLib interface you are using.

What is the current version? As I see in https://github.com/tdlib/td/releases latest is 1.3

Yes, current public version is 1.3.0. TDLib 1.4.0 will be released when it became stable enough. For now, you need to take care to not open the same database by different clients yourself.

ztdan4ik commented 6 years ago

It depends on how you created them and which TDLib interface you are using.

Working with PHP, running listener from server php run.php. Some times I terminated the process without closing the client instance. Think that is why I'm getting errors. But I have deleted all client folders _(database_directory,filesdirectory) and reboot the server. I'm using new folders, even using test phone number for new client - and the same situation, Im getting that errors.

Have one new thing before aborting:

terminate called after throwing an instance of 'std::runtime_error'
  what():  random_device::random_device(const std::string&)
Aborted
levlam commented 6 years ago

Then you likely use JSON interface under the hood and TDLib's client is created using call to td_json_client_create. You need to make sure that td_json_client_destroy is called for all created client. It is also should be useless to create more than 1 client for 1 account, so first of all td_json_client_create shouldn't be called more than once. Maybe you call run.php a lot of times in parallel or create a client on each call to run.php and never close it?

terminate called after throwing an instance of 'std::runtime_error'
  what():  random_device::random_device(const std::string&)
Aborted

It is another error. It happens if we can't gain enough entropy to seed random number generator from /dev/random, so we can't continue execution without sacrificing security. It shouldn't happen, unless someone drains a lot of data from /dev/random.

ztdan4ik commented 6 years ago

Yes Aliaksei, its my fault. I found in my script one way where could be creating more then one Client instance with same db folder. Thanks for your time and patience.