danog / MadelineProto

Async PHP client API for the telegram MTProto protocol
https://docs.madelineproto.xyz
GNU Affero General Public License v3.0
2.8k stars 636 forks source link

Exception: Could not connect to MadelineProto, please enable proc_open or disable webserver path rewrites to fix! #1390

Closed commeta closed 1 year ago

commeta commented 1 year ago

MadelineProto error in sapi mode

When trying to add an apiid & hash account, it crashes with an error

\danog\MadelineProto\Exception: Could not connect to MadelineProto, please enable proc_open or disable webserver path rewrites to fix! If you already did that, make sure the CLI version of PHP is exactly the same as the web version (same version, extensions, et cetera) and check out the MadelineProto.log file for more info about the error that prevented the IPC server from starting. in phar:///var/www/robroyru/data/www/tg.robroy.ru/madeline-8.0.0-beta143.phar/vendor/danog/madelineproto/src/API.php:331
Revision: 8.0.0-beta143
TL Trace:
<br>
API.php(213): connectToMadelineProto({})<br>
info.php(2): __construct("6281159754232") 
uname -a
Linux roru 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.6 LTS
Release:    18.04
Codename:   bionic

/opt/php82/bin/php -v
PHP 8.2.6 (cli) (built: Jun 29 2020 09:25:38) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.6, Copyright (c), by Zend Technologies

/opt/php82/bin/php -m
[PHP Modules]
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
intl
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
random
readline
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

log


Logger:             MadelineProto 8.0.0-beta143
Logger:             Copyright (C) 2016-2023 Daniil Gentili
Logger:             Licensed under AGPLv3
Logger:             https://github.com/danog/MadelineProto
Server:             Starting IPC server /var/www/roru/data/www/tg.roru.ru/6281159754232 (process)
ProcessRunner:      Starting process with '/usr/bin/php' '-dhtml_errors=0' '-ddisplay_errors=0' '-dlog_errors=1' '/var/www/roru/data/www/tg.roru.ru/madeline.php' 'madeline-ipc' '/var/www/roru/data/www/tg.roru.ru/6281159754232' '1251092755'
Exception:          fsockopen(): SSL operation failed with code 1. OpenSSL Error messages:
error:1408F10B:SSL routines:ssl3_get_record:wrong version number in WebRunner.php:122
WebRunner:          Error while sending to tls://tg.roru.ru:80: \danog\MadelineProto\Exception: fsockopen(): SSL operation failed with code 1. OpenSSL Error messages:
error:1408F10B:SSL routines:ssl3_get_record:wrong version number in phar:///var/www/roru/data/www/tg.roru.ru/madeline-8.0.0-beta143.phar/vendor/danog/madelineproto/src/Ipc/Runner/WebRunner.php:122
Revision: 8.0.0-beta143
TL Trace:
<br>
exceptionErrorHandler(2,"fsockopen(): SSL operation failed with code 1. OpenSSL Error messages:\nerror:1408F10B:SSL routines:ssl3_get_record:wrong version number","phar:\/\/\/var\/www\/roru\/data\/www\/tg.roru.ru\/madeline-8.0.0-beta143.phar\/vendor\/danog\/madelineproto\/src\/Ipc\/Runner\/WebRunner.php",122)<br>
WebRunner.php(122):     fsockopen("tls:\/\/tg.roru.ru",80)<br>
WebRunner.php(77):      selfStart("\/madeline.php?argv%5B0%5D=madeline-ipc&argv%5B1%5D=%2Fvar%2Fwww%2Froru%2Fdata%2Fwww%2Ftg.roru.ru%2F6281159754232&argv%5B2%5D=1251092755&cwd=%2Fvar%2Fwww%2Froru%2Fdata%2Fwww%2Ftg.roru.ru&MadelineSelfRestart=1")<br>
Server.php(112):        start("\/var\/www\/roru\/data\/www\/tg.roru.ru\/6281159754232",1251092755)<br>
Serialization.php(183): startMe({})<br>
AbstractDriver.php(422):    Amp\{closure}(null,null,[])<br>
AbstractDriver.php(558):    invokeMicrotasks()<br>
Revolt\EventLoop\Internal\{closure}()<br>
AbstractDriver.php(495):    start()<br>
AbstractDriver.php(534):    invokeCallbacks()<br>
Revolt\EventLoop\Internal\{closure}()<br>
AbstractDriver.php(93): start()<br>
DriverSuspension.php(99):   Revolt\EventLoop\Internal\{closure}()<br>
Future.php(251):        suspend()<br>
API.php(320):           await({})<br>
API.php(213):           connectToMadelineProto({})<br>
info.php(2):            __construct("6281159754232")
WebRunner:          Successfully connected to tls://tg.roru.ru:443!
WebRunner:          Sending payload: GET /madeline.php?argv%5B0%5D=madeline-ipc&argv%5B1%5D=%2Fvar%2Fwww%2Froru%2Fdata%2Fwww%2Ftg.roru.ru%2F6281159754232&argv%5B2%5D=1251092755&cwd=%2Fvar%2Fwww%2Froru%2Fdata%2Fwww%2Ftg.roru.ru&MadelineSelfRestart=1 HTTP/1.1
Host: tg.roru.ru

WebRunner:          Successfully connected to tcp://tg.roru.ru:80!
WebRunner:          Sending payload: GET /madeline.php?argv%5B0%5D=madeline-ipc&argv%5B1%5D=%2Fvar%2Fwww%2Froru%2Fdata%2Fwww%2Ftg.roru.ru%2F6281159754232&argv%5B2%5D=1251092755&cwd=%2Fvar%2Fwww%2Froru%2Fdata%2Fwww%2Ftg.roru.ru&MadelineSelfRestart=1 HTTP/1.1
Host: tg.roru.ru

Serialization:      MadelineProto is starting, please wait...
ProcessRunner:      Got message from worker: PHP Parse error:  syntax error, unexpected '=' in /var/www/roru/data/www/tg.roru.ru/madeline.php on line 91
ProcessRunner:      Got final message from worker: 
ProcessRunner:      Got final message from worker: 
Serialization:      MadelineProto is starting, please wait...
Serialization:      MadelineProto is starting, please wait...
Serialization:      MadelineProto is starting, please wait...
Serialization:      MadelineProto is starting, please wait...
Serialization:      MadelineProto is starting, please wait...
Serialization:      MadelineProto is starting, please wait...
Serialization:      MadelineProto is starting, please wait...
Serialization:      MadelineProto is starting, please wait...
Serialization:      MadelineProto is starting, please wait...
Serialization:      MadelineProto is starting, please wait...
Serialization:      MadelineProto is starting, please wait...
Serialization:      MadelineProto is starting, please wait...
Serialization:      MadelineProto is starting, please wait...
Serialization:      MadelineProto is starting, please wait...
Serialization:      MadelineProto is starting, please wait...
Serialization:      MadelineProto is starting, please wait...

Exception:          Could not connect to MadelineProto, please enable proc_open or disable webserver path rewrites to fix! If you already did that, make sure the CLI version of PHP is exactly the same as the web version (same version, extensions, et cetera) and check out the MadelineProto.log file for more info about the error that prevented the IPC server from starting. in API.php:331
Exception:          \danog\MadelineProto\Exception: Could not connect to MadelineProto, please enable proc_open or disable webserver path rewrites to fix! If you already did that, make sure the CLI version of PHP is exactly the same as the web version (same version, extensions, et cetera) and check out the MadelineProto.log file for more info about the error that prevented the IPC server from starting. in phar:///var/www/roru/data/www/tg.roru.ru/madeline-8.0.0-beta143.phar/vendor/danog/madelineproto/src/API.php:331
Revision: 8.0.0-beta143
TL Trace:
<br>
API.php(213):           connectToMadelineProto({})<br>
info.php(2):            __construct("6281159754232")
danog commented 1 year ago

You should switch to php 8.2 via cli (php -v should return 8.2.9)

shdehnavi commented 1 year ago

You should switch to php 8.2 via cli (php -v should return 8.2.9)

I'm already using php8.2.9 but still got the same error

danog commented 1 year ago

Including in CLI?

shdehnavi commented 1 year ago

Yes, I'm using CLI to run the bot, here is the log output:


Server:             Starting IPC server /var/www/tebot/session.madeline (process)
ProcessRunner:      Starting process with '/usr/bin/php8.2' '-dhtml_errors=0' '-ddisplay_errors=0' '-dlog_errors=1' '/var/www/tebot/vendor/danog/madelineproto/src/Ipc/Runner/entry.php' 'madeline-ipc' '/var/www/tebot/session.madeline' '511505229'
ProcessRunner:      Got message from worker: PHP Warning:  Module "uv" is already loaded in Unknown on line 0
Serialization:      MadelineProto is starting, please wait...
Serialization:      Connected to IPC socket!
APIWrapper:         Restarting to full instance (again): sending shutdown signal!
Serialization:      MadelineProto is starting, please wait...
Serialization:      Connected to IPC socket!
APIWrapper:         Restarting to full instance (again): sending shutdown signal!
Serialization:      MadelineProto is starting, please wait...
Serialization:      Connected to IPC socket!
APIWrapper:         Restarting to full instance (again): sending shutdown signal!
Serialization:      MadelineProto is starting, please wait...
Serialization:      Connected to IPC socket!
APIWrapper:         Restarting to full instance (again): sending shutdown signal!
Serialization:      MadelineProto is starting, please wait...
Serialization:      Connected to IPC socket!
APIWrapper:         Restarting to full instance (again): sending shutdown signal!
Serialization:      MadelineProto is starting, please wait...
Serialization:      Connected to IPC socket!
APIWrapper:         Restarting to full instance (again): sending shutdown signal!
Serialization:      MadelineProto is starting, please wait...
Serialization:      Connected to IPC socket!
APIWrapper:         Restarting to full instance (again): sending shutdown signal!
Serialization:      MadelineProto is starting, please wait...
Serialization:      Connected to IPC socket!
APIWrapper:         Restarting to full instance (again): sending shutdown signal!
Serialization:      MadelineProto is starting, please wait...
Serialization:      Connected to IPC socket!
APIWrapper:         Restarting to full instance (again): sending shutdown signal!
Serialization:      MadelineProto is starting, please wait...
Serialization:      Connected to IPC socket!
APIWrapper:         Restarting to full instance (again): sending shutdown signal!
Serialization:      MadelineProto is starting, please wait...
Serialization:      Connected to IPC socket!
APIWrapper:         Restarting to full instance (again): sending shutdown signal!
Serialization:      MadelineProto is starting, please wait...
Exception:          filetype(): Lstat failed for /var/www/tebot/session.madeline/ipc in functions.php:40
Serialization:      filetype(): Lstat failed for /var/www/tebot/session.madeline/ipc while connecting to IPC socket
ProcessRunner:      Got final message from worker: 
ProcessRunner:      Got final message from worker: 
Server:             IPC server started successfully!
ClientAbstract:     Got exception while reconnecting in IPC client: RuntimeException: The endpoint does not exist! in /var/www/tebot/vendor/danog/ipc/lib/functions.php:36
shdehnavi commented 1 year ago

here is the last exception:

Server:             Starting IPC server /var/www/tebot/session.madeline (process)
ProcessRunner:      Starting process with '/usr/bin/php8.2' '-dhtml_errors=0' '-ddisplay_errors=0' '-dlog_errors=1' '/var/www/tebot/vendor/danog/madelineproto/src/Ipc/Runner/entry.php' 'madeline-ipc' '/var/www/tebot/session.madeline' '762603908'
ProcessRunner:      Got message from worker: PHP Warning:  Module "uv" is already loaded in Unknown on line 0
Exception:          Could not connect to MadelineProto, please enable proc_open or disable webserver path rewrites to fix! If you already did that, make sure the CLI version of PHP is exactly the same as the web version (same version, extensions, et cetera) and check out the MadelineProto.log file for more info about the error that prevented the IPC server from starting. in API.php:331
Exception:          \danog\MadelineProto\Exception: Could not connect to MadelineProto, please enable proc_open or disable webserver path rewrites to fix! If you already did that, make sure the CLI version of PHP is exactly the same as the web version (same version, extensions, et cetera) and check out the MadelineProto.log file for more info about the error that prevented the IPC server from starting. in /var/www/tebot/vendor/danog/madelineproto/src/API.php:331
Revision: 8.0.0-beta143
TL Trace:

API.php(294):           connectToMadelineProto()
AbstractAPI.php(77):    reconnectFull()
AbstractAPI.php(65):    startAndLoopLogic()
EventHandler.php(73):   startAndLoopInternal()
bot.php(25):            startAndLoop()

also I checked the /etc/php/8.2/cli/php.ini configuration and disable_functions doesn't contain 'proc_open'

danog commented 1 year ago

Try with the latest beta, and open a new issue with full logs if it happens again please.