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

how to set mysql to defrent port and use it by TelegramServerApi #168

Closed alirayaneh closed 1 month ago

alirayaneh commented 1 month ago

i want to use this project in a configed web server that has installed mysql . when i start this project in this server i have get loop error

docker compose run --rm api [+] Creating 1/0 ✔ Container telegramapiserver-mysql-1 Running 0.0s Installing dependencies from lock file (including require-dev) Verifying lock file contents can be installed on current platform. Nothing to install, update or remove Generating autoload files 73 packages you are using are looking for funding. Use thecomposer fundcommand to find out more! [INFO wait] -------------------------------------------------------- [INFO wait] docker-compose-wait 2.12.1 [INFO wait] --------------------------- [DEBUG wait] Starting with configuration: [DEBUG wait] - Hosts to be waiting for: [mysql:3306] [DEBUG wait] - Paths to be waiting for: [] [DEBUG wait] - Timeout before failure: 30 seconds [DEBUG wait] - TCP connection timeout before retry: 5 seconds [DEBUG wait] - Sleeping time before checking for hosts/paths availability: 0 seconds [DEBUG wait] - Sleeping time once all hosts/paths are available: 0 seconds [DEBUG wait] - Sleeping time between retries: 1 seconds [DEBUG wait] -------------------------------------------------------- [INFO wait] Checking availability of host [mysql:3306] [INFO wait] Host [mysql:3306] not yet available... [INFO wait] Host [mysql:3306] not yet available... [INFO wait] Host [mysql:3306] not yet available... [INFO wait] Host [mysql:3306] not yet available... [INFO wait] Host [mysql:3306] not yet available... [INFO wait] Host [mysql:3306] not yet available... [INFO wait] Host [mysql:3306] not yet available... [INFO wait] Host [mysql:3306] not yet available... [INFO wait] Host [mysql:3306] not yet available... [INFO wait] Host [mysql:3306] not yet available... [INFO wait] Host [mysql:3306] not yet available...

how to change mysql defult port in this project . when try to change docker-compose.yml at this line mysql: extends: file: docker-compose.base.yml service: base-mysql ports:

# MYSQL Settings. Required, when DB_TYPE=mysql DB_HOST=localhost DB_PORT=3309 DB_USER=root DB_PASSWORD= it not effected . and repeat error.

xtrime-ru commented 1 month ago

Docker containers use internal ports for communication. For example TAS uses mysql:3306 address to connect to mysql. Do not change this config.

127.0.0.1:3309 is only for external mysql clients. For example, to debug. You can remove ports directive entirely from docker compose, if there is port conflict on your host.

alirayaneh commented 1 month ago

thanx for response . I reverted all the changes and deleted the ports value `ports:

docker compose up

[+] Running 2/2 ✔ Container telegramapiserver-mysql-1 Recreated 2.4s ✔ Container telegramapiserver-api-1 Recreated 0.1s Attaching to telegramapiserver-api-1, telegramapiserver-mysql-1 telegramapiserver-mysql-1 | 2024-10-03 08:46:59+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:11.4.3+maria~ubu2404 started. telegramapiserver-mysql-1 | 2024-10-03 08:47:00+00:00 [Warn] [Entrypoint]: /sys/fs/cgroup/blkio:/docker/b51b5cf65d2efb3f1e36687a7d7d17aa9d3fac81d458adb4fbae894b18e8f223 telegramapiserver-mysql-1 | 11:rdma:/docker/b51b5cf65d2efb3f1e36687a7d7d17aa9d3fac81d458adb4fbae894b18e8f223 telegramapiserver-mysql-1 | 10:freezer:/docker/b51b5cf65d2efb3f1e36687a7d7d17aa9d3fac81d458adb4fbae894b18e8f223 telegramapiserver-mysql-1 | 9:cpu,cpuacct:/docker/b51b5cf65d2efb3f1e36687a7d7d17aa9d3fac81d458adb4fbae894b18e8f223 telegramapiserver-mysql-1 | 8:pids:/docker/b51b5cf65d2efb3f1e36687a7d7d17aa9d3fac81d458adb4fbae894b18e8f223 telegramapiserver-mysql-1 | 7:devices:/docker/b51b5cf65d2efb3f1e36687a7d7d17aa9d3fac81d458adb4fbae894b18e8f223 telegramapiserver-mysql-1 | 6:perf_event:/docker/b51b5cf65d2efb3f1e36687a7d7d17aa9d3fac81d458adb4fbae894b18e8f223 telegramapiserver-mysql-1 | 5:memory:/docker/b51b5cf65d2efb3f1e36687a7d7d17aa9d3fac81d458adb4fbae894b18e8f223 telegramapiserver-mysql-1 | 4:cpuset:/docker/b51b5cf65d2efb3f1e36687a7d7d17aa9d3fac81d458adb4fbae894b18e8f223 telegramapiserver-mysql-1 | 3:net_cls,net_prio:/docker/b51b5cf65d2efb3f1e36687a7d7d17aa9d3fac81d458adb4fbae894b18e8f223 telegramapiserver-mysql-1 | 2:hugetlb:/docker/b51b5cf65d2efb3f1e36687a7d7d17aa9d3fac81d458adb4fbae894b18e8f223 telegramapiserver-mysql-1 | 1:name=systemd:/docker/b51b5cf65d2efb3f1e36687a7d7d17aa9d3fac81d458adb4fbae894b18e8f223 telegramapiserver-mysql-1 | 0::/docker/b51b5cf65d2efb3f1e36687a7d7d17aa9d3fac81d458adb4fbae894b18e8f223/memory.pressure not writable, functionality unavailable to MariaDB telegramapiserver-mysql-1 | 2024-10-03 08:47:00+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' telegramapiserver-mysql-1 | 2024-10-03 08:47:00+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:11.4.3+maria~ubu2404 started. telegramapiserver-mysql-1 | 2024-10-03 08:47:00+00:00 [Note] [Entrypoint]: MariaDB upgrade not required telegramapiserver-mysql-1 | 2024-10-03 8:47:00 0 [Note] Starting MariaDB 11.4.3-MariaDB-ubu2404 source revision 5ab81ffe0097a22a774957df28c5223cf0201de3 se telegramapiserver-mysql-1 | rver_uid I8/zqvbJN3VHwCOp+HNWk+OqH0E= as process 1 telegramapiserver-mysql-1 | 2024-10-03 8:47:00 0 [Note] InnoDB: Compressed tables use zlib 1.3 telegramapiserver-mysql-1 | 2024-10-03 8:47:00 0 [Note] InnoDB: Using transactional memory telegramapiserver-mysql-1 | 2024-10-03 8:47:00 0 [Note] InnoDB: Number of transaction pools: 1 telegramapiserver-mysql-1 | 2024-10-03 8:47:00 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions telegramapiserver-mysql-1 | 2024-10-03 8:47:00 0 [Note] mariadbd: O_TMPFILE is not supported on /tmp (disabling future attempts) telegramapiserver-mysql-1 | 2024-10-03 8:47:00 0 [Warning] mariadbd: io_uring_queue_init() failed with errno 95 telegramapiserver-mysql-1 | 2024-10-03 8:47:00 0 [Warning] InnoDB: liburing disabled: falling back to innodb_use_native_aio=OFF telegramapiserver-mysql-1 | 2024-10-03 8:47:00 0 [Note] InnoDB: Initializing buffer pool, total size = 128.000MiB, chunk size = 2.000MiB telegramapiserver-mysql-1 | 2024-10-03 8:47:00 0 [Note] InnoDB: Completed initialization of buffer pool telegramapiserver-mysql-1 | 2024-10-03 8:47:00 0 [Note] InnoDB: File system buffers for log disabled (block size=512 bytes) telegramapiserver-mysql-1 | 2024-10-03 8:47:00 0 [Note] InnoDB: End of log at LSN=500134586 telegramapiserver-mysql-1 | 2024-10-03 8:47:00 0 [Note] InnoDB: Opened 3 undo tablespaces telegramapiserver-mysql-1 | 2024-10-03 8:47:00 0 [Note] InnoDB: 128 rollback segments in 3 undo tablespaces are active. telegramapiserver-mysql-1 | 2024-10-03 8:47:00 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait .. telegramapiserver-mysql-1 | . telegramapiserver-mysql-1 | 2024-10-03 8:47:00 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB. telegramapiserver-mysql-1 | 2024-10-03 8:47:00 0 [Note] InnoDB: log sequence number 500134586; transaction id 2469 telegramapiserver-mysql-1 | 2024-10-03 8:47:00 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool telegramapiserver-mysql-1 | 2024-10-03 8:47:00 0 [Note] Plugin 'FEEDBACK' is disabled. telegramapiserver-mysql-1 | 2024-10-03 8:47:00 0 [Note] Plugin 'wsrep-provider' is disabled. telegramapiserver-mysql-1 | 2024-10-03 8:47:01 0 [Note] InnoDB: Buffer pool(s) load completed at 241003 8:47:01 telegramapiserver-api-1 | Installing dependencies from lock file (including require-dev) telegramapiserver-api-1 | Verifying lock file contents can be installed on current platform. telegramapiserver-api-1 | Nothing to install, update or remove telegramapiserver-api-1 | Generating autoload files telegramapiserver-api-1 | 73 packages you are using are looking for funding. telegramapiserver-api-1 | Use the composer fund command to find out more! telegramapiserver-api-1 | [INFO wait] -------------------------------------------------------- telegramapiserver-api-1 | [INFO wait] docker-compose-wait 2.12.1 telegramapiserver-api-1 | [INFO wait] --------------------------- telegramapiserver-api-1 | [DEBUG wait] Starting with configuration: telegramapiserver-api-1 | [DEBUG wait] - Hosts to be waiting for: [mysql:3306] telegramapiserver-api-1 | [DEBUG wait] - Paths to be waiting for: [] telegramapiserver-api-1 | [DEBUG wait] - Timeout before failure: 30 seconds telegramapiserver-api-1 | [DEBUG wait] - TCP connection timeout before retry: 5 seconds telegramapiserver-api-1 | [DEBUG wait] - Sleeping time before checking for hosts/paths availability: 0 seconds telegramapiserver-api-1 | [DEBUG wait] - Sleeping time once all hosts/paths are available: 0 seconds telegramapiserver-api-1 | [DEBUG wait] - Sleeping time between retries: 1 seconds telegramapiserver-api-1 | [DEBUG wait] -------------------------------------------------------- telegramapiserver-api-1 | [INFO wait] Checking availability of host [mysql:3306] telegramapiserver-api-1 | [INFO wait] Host [mysql:3306] not yet available... telegramapiserver-api-1 | [INFO wait] Host [mysql:3306] not yet available... telegramapiserver-mysql-1 | 2024-10-03 8:47:08 0 [Note] Server socket created on IP: '0.0.0.0'. telegramapiserver-mysql-1 | 2024-10-03 8:47:08 0 [Note] Server socket created on IP: '::'. telegramapiserver-mysql-1 | 2024-10-03 8:47:08 0 [Note] mariadbd: ready for connections. telegramapiserver-mysql-1 | Version: '11.4.3-MariaDB-ubu2404' socket: '/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution telegramapiserver-api-1 | [INFO wait] Host [mysql:3306] not yet available... telegramapiserver-api-1 | [INFO wait] Host [mysql:3306] not yet available... telegramapiserver-api-1 | [INFO wait] Host [mysql:3306] not yet available... telegramapiserver-api-1 | [INFO wait] Host [mysql:3306] not yet available... telegramapiserver-api-1 | [INFO wait] Host [mysql:3306] not yet available... telegramapiserver-api-1 | [INFO wait] Host [mysql:3306] not yet available... telegramapiserver-api-1 | [INFO wait] Host [mysql:3306] not yet available... telegramapiserver-api-1 | [INFO wait] Host [mysql:3306] not yet available... telegramapiserver-api-1 | [INFO wait] Host [mysql:3306] not yet available... telegramapiserver-api-1 | [INFO wait] Host [mysql:3306] not yet available... telegramapiserver-api-1 | [INFO wait] Host [mysql:3306] not yet available... telegramapiserver-api-1 | [INFO wait] Host [mysql:3306] not yet available... telegramapiserver-api-1 | [INFO wait] Host [mysql:3306] not yet available... telegramapiserver-api-1 | [INFO wait] Host [mysql:3306] not yet available... telegramapiserver-api-1 | [ERROR wait] Timeout! After 30 seconds some hosts are still not reachable telegramapiserver-api-1 exited with code 0 telegramapiserver-api-1 | Installing dependencies from lock file (including require-dev) telegramapiserver-api-1 | Verifying lock file contents can be installed on current platform. telegramapiserver-api-1 | Nothing to install, update or remove telegramapiserver-api-1 | Generating autoload files telegramapiserver-api-1 | 73 packages you are using are looking for funding. telegramapiserver-api-1 | Use the composer fund command to find out more! telegramapiserver-api-1 | [INFO wait] -------------------------------------------------------- telegramapiserver-api-1 | [INFO wait] docker-compose-wait 2.12.1 telegramapiserver-api-1 | [INFO wait] --------------------------- telegramapiserver-api-1 | [DEBUG wait] Starting with configuration: telegramapiserver-api-1 | [DEBUG wait] - Hosts to be waiting for: [mysql:3306] telegramapiserver-api-1 | [DEBUG wait] - Paths to be waiting for: [] telegramapiserver-api-1 | [DEBUG wait] - Timeout before failure: 30 seconds telegramapiserver-api-1 | [DEBUG wait] - TCP connection timeout before retry: 5 seconds telegramapiserver-api-1 | [DEBUG wait] - Sleeping time before checking for hosts/paths availability: 0 seconds telegramapiserver-api-1 | [DEBUG wait] - Sleeping time once all hosts/paths are available: 0 seconds telegramapiserver-api-1 | [DEBUG wait] - Sleeping time between retries: 1 seconds telegramapiserver-api-1 | [DEBUG wait] -------------------------------------------------------- telegramapiserver-api-1 | [INFO wait] Checking availability of host [mysql:3306] telegramapiserver-api-1 | [INFO wait] Host [mysql:3306] not yet available... telegramapiserver-api-1 | [INFO wait] Host [mysql:3306] not yet available... telegramapiserver-api-1 | [INFO wait] Host [mysql:3306] not yet available... telegramapiserver-api-1 | [INFO wait] Host [mysql:3306] not yet available... telegramapiserver-api-1 | [INFO wait] Host [mysql:3306] not yet available... ^CGracefully stopping... (press Ctrl+C again to force) Aborting on container exit... [+] Stopping 2/2 ✔ Container telegramapiserver-api-1 Stopped 0.3s ✔ Container telegramapiserver-mysql-1 Stopped 0.5s canceled

xtrime-ru commented 1 month ago

Mysql is still not accessable. Does it worked in past? If yes - try to recreate

docker compose down
docker compose up

If it never worked, then it could be issue with old docker version or old host system.

alirayaneh commented 1 month ago

The service was working properly. Until I installed the virtualmain system, the service stopped working and started to fail to connect to MySQL. Now I realized that the MySQL service is running and this error is probably due to other reasons. Because I was able to connect to the MySQL container through the MySQL debug port, but I saw that the database was not created in it. However, the error [INFO wait] Host [mysql:3306] not yet available... is still repeating

xtrime-ru commented 1 month ago

Maybe new software has broken docker iptables rules. I suggest reinstall docker or completely reintsall your VPS/server

alirayaneh commented 1 month ago

ok thanx . i use snap to install docker . and trying to reinstall it.

alirayaneh commented 1 month ago

i disable firewallID on virtualmin it s work. for re enable firewall . Should I leave the output or input ports open? Currently, I have opened ports 9503, 9504, 9507.

xtrime-ru commented 1 month ago

By default there is no open ports. They listen requests from 127.0.0.1, not 0.0.0.0. I do not recomment to edit port forwarding in docker compose if you not sure. By default its 100% secure.