xtrime-ru / TelegramApiServer

Fast, simple, async php telegram api server: MadelineProto + Amp HTTP Server
https://tg.i-c-a.su
MIT License
576 stars 130 forks source link

Nothing happens "Authorizing session: session" #47

Closed 4n70w4 closed 4 years ago

4n70w4 commented 4 years ago

Hi! I run in docker:

php server.php --docker --port=9500 --session=session
[2020-08-09 14:18:01] [warning]
Starting MadelineProto...

[2020-08-09 14:18:01] [notice] MadelineProto
[2020-08-09 14:18:01] [notice] Copyright (C) 2016-2020 Daniil Gentili
[2020-08-09 14:18:01] [notice] Licensed under AGPLv3
[2020-08-09 14:18:01] [notice] https://github.com/danog/MadelineProto
[2020-08-09 14:18:01] [debug] Istantiating DataCenter...
[2020-08-09 14:18:01] [debug] Translating TL schemas...
[2020-08-09 14:18:01] [info] Loading TL schemes...
[2020-08-09 14:18:01] [info] Parsing TL_mtproto_v1.tl...
[2020-08-09 14:18:01] [error] CRC32 mismatch (29c1636d, 73f1f8dc) for msg_container#73f1f8dc messages:vector<%Message> = MessageContainer;
[2020-08-09 14:18:01] [debug] Translating objects...
[2020-08-09 14:18:01] [debug] Translating methods...
[2020-08-09 14:18:01] [info] Parsing TL_telegram_v113.tl...
[2020-08-09 14:18:01] [debug] Translating objects...
[2020-08-09 14:18:01] [debug] Translating methods...
[2020-08-09 14:18:01] [info] Parsing TL_secret.tl...
[2020-08-09 14:18:01] [debug] Translating objects...
[2020-08-09 14:18:01] [debug] Translating methods...
[2020-08-09 14:18:01] [info] Parsing TL_botAPI.tl...
[2020-08-09 14:18:01] [debug] Translating objects...
[2020-08-09 14:18:01] [debug] Translating methods...
[2020-08-09 14:18:01] [warning] Creating/checking table tmp_1cb2cfdf114da16_MTProto_chats
[2020-08-09 14:18:01] [info]
[
    "\n            CREATE TABLE IF NOT EXISTS `tmp_1cb2cfdf114da16_MTProto_chats`\n            (\n                `key` VARCHAR(255) NOT NULL,\n                `value` MEDIUMBLOB NULL,\n                `ts` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n                PRIMARY KEY (`key`)\n            )\n            ENGINE = InnoDB\n            CHARACTER SET 'utf8mb4' \n            COLLATE 'utf8mb4_general_ci'\n        ",
    []
]
[2020-08-09 14:18:01] [warning]
TelegramApiServer ready.
Number of sessions: 1.
[2020-08-09 14:18:01] [debug] Starting
[2020-08-09 14:18:01] [warning] Running in production with assertions enabled is not recommended; it has a negative impacton performance. Disable assertions in php.ini (zend.assertions = -1) for best performance or set the debug mode option to hide this warning.
[2020-08-09 14:18:01] [debug] Started
[2020-08-09 14:18:01] [info] Listening on http://0.0.0.0:9500/
Authorizing session: session

And nothing happens even after 10 minutes.

In mysql 4 empty tables:

image

I see empty file sessions/session.madeline.ipc.

Proxy works:

curl -socks5-hostname "XXXX:XXXX@XXXXX:8000" https://api.telegram.org
<html>
<head><title>302 Found</title></head>
<body>
<center><h1>302 Found</h1></center>
<hr><center>nginx/1.16.1</center>
</body>
</html>
# ENV file version
# Check for outdated .env files
VERSION=1

SERVER_ADDRESS=0.0.0.0
SERVER_PORT=9503

MEMORY_LIMIT=256M
TIMEZONE=UTC

# List of allowed clients. Separate with comma.
# Leave blanc, to allow requests from all IP (dangerous!)
IP_WHITELIST=127.0.0.1

# TELEGRAM CLIENT
TELEGRAM_API_ID=XXX
TELEGRAM_API_HASH=XXXXXXXXXXXX
# FATAL_ERROR = 0; ERROR = 1; WARNING = 2; const NOTICE = 3; VERBOSE = 4; ULTRA_VERBOSE = 5;
LOGGER_LEVEL=5

# TELEGRAM SOCKS5 PROXY (optional)
TELEGRAM_PROXY_ADDRESS=XXXXXXXXX
TELEGRAM_PROXY_PORT=8000
TELEGRAM_PROXY_USERNAME=XXXXX
TELEGRAM_PROXY_PASSWORD=XXXXX

# DB
#   memory
#       Keep all data in memory/session file.
#       This is default behavior
#   mysql
#       Keep part of data in mysql database.
#       Reduce memory consumption and session size. Beta function.
#       MariaDb + InnoDb Preffered.
#       Tables and DB will be created if not exists.

#   Change this type to convert session:
DB_TYPE=mysql
#   MYSQL Settings. Required, when DB_TYPE=mysql
MYSQL_HOST=mysql
MYSQL_PORT=3306
MYSQL_USER=root
MYSQL_PASSWORD=
MYSQL_DATABASE=MadelineProto
MYSQL_MAX_CONNECTIONS=10
MYSQL_IDLE_TIMEOUT=60
#   Recent data will be stored in memory this amount of time:
MYSQL_CACHE_TTL="+5 minutes"
4n70w4 commented 4 years ago

I clean TELEGRAM_API_ID and TELEGRAM_API_HASH from .env and run:

php server.php --docker --port=9500 --session=session
Starting MadelineProto...

You did not define a valid API ID/API hash. Do you want to define it now manually, or automatically? (m/a)
Note that you can also provide the API parameters directly in the code using the settings: https://docs.madelineproto.xyz/docs/SETTINGS.html#settingsapp_infoapi_id
Your choice (m/a): [2020-08-09 14:37:47] [warning]
TelegramApiServer ready.
Number of sessions: 1.
[2020-08-09 14:37:47] [debug] Starting
[2020-08-09 14:37:47] [warning] Running in production with assertions enabled is not recommended; it has a negative impacton performance. Disable assertions in php.ini (zend.assertions = -1) for best performance or set the debug mode option to hide this warning.
[2020-08-09 14:37:47] [debug] Started
[2020-08-09 14:37:47] [info] Listening on http://0.0.0.0:9500/
Authorizing session: session

Press enter

Enter a phone number that is already registered on Telegram: +7XXXXXXX
Enter the verification code you received in telegram: XXXXXX

I recieve verification code but after submit code also nothing happens.

xtrime-ru commented 4 years ago

For docker you need to fill .env.docker file. .env file id used when you run composer version without docker.

xtrime-ru commented 4 years ago

Sometimes readline questions followed by log messages, so you need to read few lines before. On your second message you got question: You did not define a valid API ID/API hash. Do you want to define it now manually, or automatically? (m/a) You need to enter 'm', and press enter (if you not define app_id and app_hash in .env.docker). Then enter phone, enter code and password(if you have 2fa enabled). Then you can check your accounts: curl "http://127.0.0.1:9500/system/getSessionList"

If its authorized, then you save your session (some times its not saved automatically): curl "http://127.0.0.1:9500/api/serialize" Then you can end your setup with ctrl+c, exit from docker shell and restart docker container: docker-compose restart teleram-api-server

After that you can send requests to 127.0.0.1:9503

You can write me in telegram: https://t.me/xtrime You from Moscow? We can speak russian :)

4n70w4 commented 4 years ago

Thanks for answers.

My contents of .env and .env.docker are identical.

For the experiment, I created a new Ubuntu 18 virtual machine on Vultr (analogue of the digital ocean). And everything worked out. In 5-10 minutes everything was installed, started and worked.

The problems that I described above were in docker on Windows 10. I tried docker over Hyper-V and over WSL2.

Nothing happens on "Authorizing session: session".

But https://github.com/unreal4u/telegram-api works in docker on Windows.

In the coming days, I will try again to reproduce it on Windows, and if there are any questions, I will contact you via telegram.

xtrime-ru commented 4 years ago

Thanks for report. Ill check tomorrow in docker for mac. I want to mention tg.i-c-a.su uses docker version, but i used existing session file when i was migrating to docker.

xtrime-ru commented 4 years ago

I guess i know what caused your issue! I forgot to update readme after last feature.

Correct command to add new session in docker: php server.php -p=9500 -s=session --docker -e=.env.docker I will change readme now.