Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple accounts #40

Closed
goroshevsky opened this issue Feb 5, 2018 · 13 comments
Closed

Multiple accounts #40

goroshevsky opened this issue Feb 5, 2018 · 13 comments
Labels

Comments

@goroshevsky
Copy link

How can I run one TDLib instance with multiple accounts?

@levlam
Copy link
Contributor

levlam commented Feb 5, 2018

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.

@DerAlSem
Copy link

DerAlSem commented Apr 7, 2019

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
)

@levlam
Copy link
Contributor

levlam commented Apr 7, 2019

@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.

@DerAlSem
Copy link

DerAlSem commented Apr 7, 2019

Unbelievably stupid typo.
Thanks pal!

@SavostinVladimir
Copy link

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

@DerAlSem
Copy link

DerAlSem commented Aug 28, 2019 via email

@SavostinVladimir
Copy link

No, I meant to store data in postgres for example

@levlam
Copy link
Contributor

levlam commented Aug 28, 2019

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

@DerAlSem
Copy link

DerAlSem commented Aug 28, 2019 via email

@SavostinVladimir
Copy link

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

@DerAlSem
Copy link

DerAlSem commented Aug 28, 2019 via email

@SavostinVladimir
Copy link

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

@RememberTheAir
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants