Td: Multiple accounts

Created on 5 Feb 2018  ·  13Comments  ·  Source: tdlib/td

How can I run one TDLib instance with multiple accounts?

question

Most helpful comment

I love when you think you might get something out of a conversation and suddenly everyone starts to write in their mother language like

All 13 comments

One TDLib Client can manage only one account, but there is no limit on number of clients that can be created in one process. So you can create as much TDLib Clients as you want and initialize them with different database and file folders for different accounts.

Is there a reason for this method not to work? I mean, see i run first instance, let's say phone_number is 111222, here's tdlib parameters:

(
[use_test_dc_] => 1
[database_direcotry] => /home/tdlib/storage/111222/db
[files_directory] => /home/tdlib/storage/111222/files
[use_message_database] => 1
[use_file_database] => 1
)

if i try to run second instance with phonenumber 333444, i'm getting this:

(
[use_test_dc_] => 1
[database_direcotry] => /home/tdlib/storage/333444/db
[files_directory] => /home/tdlib/storage/333444/files
[use_message_database] => 1
[use_file_database] => 1
)

after 3-5 seconds:

(
[@type] => error
[code] => 400
[message] => Can't lock file because it is already in use; check for another program instance running
)

@DerAlSem You have misprint in "database_direcotry", so the database directory isn't specified at all and current directory is used. TDLib noticed that and refused to open the same database twice.

Unbelievably stupid typo.
Thanks pal!

Hi!
Is there way to store multiple sessions in arbitrary storage (without database_directory and file_directory) with tdlib_json_client?

Yes, you can. Change "database directory" when initiating the lib.

On Wed, Aug 28, 2019 at 1:13 PM SavostinVladimir notifications@github.com
wrote:

Hi!
Is there way to store multiple sessions in arbitrary storage (without
database_directory and file_directory) with tdlib_json_client?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/tdlib/td/issues/40?email_source=notifications&email_token=ACO6OJ7PO65N5UNTG6JNVBLQGZFVHA5CNFSM4EPIBRN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5KTPEI#issuecomment-525678481,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACO6OJ2ESOFO7645JZE2UFDQGZFVHANCNFSM4EPIBRNQ
.

No, I meant to store data in postgres for example

@SavostinVladimir This isn't possible. You can't change a way the data is stored by TDLib.

По-русски напишу, один фиг тут одни русские, надеюсь, гит меня за это не
забанит.

Владимир, какие данные ты хочешь хранить? Типа там файлы и т.д. всё что
прилетает? Или что-то еще? У меня все данные в sqlite хранятся. Про
пользователей, про чаты.

On Wed, Aug 28, 2019 at 5:51 PM SavostinVladimir notifications@github.com
wrote:

No, I meant to store data in postgres for example


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/tdlib/td/issues/40?email_source=notifications&email_token=ACO6OJ5PNQUWQHJT2OXRKU3QG2GHHA5CNFSM4EPIBRN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5LMRVQ#issuecomment-525781206,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACO6OJ6OPBGPEV3HM4DNASTQG2GHHANCNFSM4EPIBRNQ
.

Я хочу хранить именно сессии. Допустим у меня 100500 разных пользователей и я не хочу их постоянно логинить через телефон и код. Мне надо хранить в постгрес данные всех этих 100500 сессий. Но в tdlib, эту заботу на себя берёт td_json_client, храня все что связано с пользователем в отдельной директории. Но создавать кучу директорий для каждого отдельного пользователя мне не подходит.
Пробовал поискать библиотеки реализующие mtproto, но там тоже максимум что я нашёл - это сохранить одну сессию в файлик. Единственное что приходит в голову пока, это немного поменять реализацию такой библиотеки под себя (чтобы сессия могла загружаться/выгружаться в постгрес)

Логинить через код и телефон не надо каждый раз. Логинишь один раз, сессия
сохраняется на диск. Именно тдлиб сохраняет ее на диск, других вариантов
нет. Но тебе какая разница? Указываешь каждому пользователю свое место
хранение и всё. В чем проблема именно?

On Wed, Aug 28, 2019 at 7:28 PM SavostinVladimir notifications@github.com
wrote:

Я хочу хранить именно сессии. Допустим у меня 100500 разных пользователей
и я не хочу их постоянно логинить через телефон и код. Мне надо хранить в
постгрес данные всех этих 100500 сессий. Но в tdlib, эту заботу на себя
берёт td_json_client, храня все что связано с пользователем в отдельной
директории. Но создавать кучу директорий для каждого отдельного
пользователя мне не подходит.
Пробовал поискать библиотеки реализующие mtproto, но там тоже максимум что
я нашёл - это сохранить одну сессию в файлик. Единственное что приходит в
голову пока, это немного поменять реализацию такой библиотеки под себя
(чтобы сессия могла загружаться/выгружаться в постгрес)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/tdlib/td/issues/40?email_source=notifications&email_token=ACO6OJ6QPUWVWOB3QL23OVTQG2RTTA5CNFSM4EPIBRN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5LWMQQ#issuecomment-525821506,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACO6OJ5IHVLFUR3XED4GW4DQG2RTTANCNFSM4EPIBRNQ
.

Проблема в том что у меня куча микросервисов которые должны работать с этими базами, если они на одной машине то все норм. А если расширяться на несколько машин, то и все базы надо расшаривать. Именно поэтому хотелось бы найти вариант самому хэндлить сессии. Тогда я мог бы класть все в единственный инстанс постгрес, а остальные обращались бы к нему

I love when you think you might get something out of a conversation and suddenly everyone starts to write in their mother language like

Was this page helpful?
0 / 5 - 0 ratings