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

Doesn't connect with proxy: Undefined array key -1 in vendor/danog/madelineproto/src/Stream/ConnectionContext.php:290 #1384

Closed misksa closed 1 year ago

misksa commented 1 year ago

hi 👋 I'm trying to set up a proxy for the session, but I get an error when trying to connect: Undefined array key -1 in /vendor/danog/madelineproto/src/Stream/ConnectionContext.php:290

my code: ----------app info--------------- > $settings = new Settings; > $appInfo = (new AppInfo()) > ->setApiId((int)$apiId) > ->setApiHash($apiHash); > $settings->setAppInfo($appInfo); ----------Connection--------------- > $connection = new Connection; > $connection->addProxy( > HttpProxy::class, > [ > 'address' => $_ENV['PROXY_ADDRESS'], > 'port' => $_ENV['PROXY_PORT'], > 'username' => $login, > 'password' => $_ENV['PROXY_PASSWORD'], > ] > ); > $settings->setConnection($connection); ----------Logging--------------- > $logger = (new LoggerSettings) > ->setType(Logger::FILE_LOGGER) > ->setExtra('./accounts_log/'.$phone.'.log') > ->setMaxSize(50 * 1024 * 1024); > $settings->setLogger($logger); ----------Instance--------------- > $api = new API('session_name', $settings); > $api->phoneLogin($phone);
Full log: > TL: Loading; > TL schemes...; > TL: Parsing TL_telegram_v160.tl... > TL: Parsing TL_mtproto_v1.tl... > TL: Parsing TL_secret.tl... > MTProto: Filling database cache. This can take a few minutes. > MTProto: The IPC settings have changed! > MTProto: The serialization settings have changed! > MTProto: Cache filled. > Exception: stream_socket_server(): Unable to connect to unix:///home/ubuntu/telegramMPT/public/./session/81bb087d7dcf4429ae23713327ea460e/ipc (Unknown error) in IpcServer.php:105 > Exception: stream_socket_server(): Unable to connect to unix:///home/ubuntu/telegramMPT/public/./session/81bb087d7dcf4429ae23713327ea460e/callback.ipc (Unknown error) in IpcServer.php:105 > TL: Loading TL schemes... > TL: Parsing TL_telegram_v160.tl... > TL: Parsing TL_mtproto_v1.tl... > TL: Parsing TL_secret.tl... > DataCenter: Connecting to DC 2 from scratch > DataCenterConnection: Trying shared connection via tcp://149.154.167.51:443 main DC 2, via ipv4 using AbridgedStream => HttpProxy ({"address":"example1","port":"example","username":"example","password":"example"}) => BufferedRawStream => DefaultStream (-1) > Connection: Connecting to DC 2.0 > Session: Resetting session in DC 2.0... > LoggerLoop, popubamba1: Pausing robin loop DC -2 for 10 > Exception: Undefined array key -1 in ConnectionContext.php:290 > DataCenter: Connection failed (2): \danog\MadelineProto\Exception: Undefined array key -1 in /home/ubuntu/telegramMPT/vendor/danog/madelineproto/src/Stream/ConnectionContext.php:290 > Revision: 8.0.0-beta130 > TL Trace: > ConnectionContext.php(290): exceptionErrorHandler() > BufferedRawStream.php(52): getStream() > HttpProxy.php(126): connect() > ConnectionContext.php(295): connect() > AbridgedStream.php(44): getStream() > ConnectionContext.php(295): connect() > Connection.php(262): getStream() > DataCenterConnection.php(487): connect() > DataCenterConnection.php(461): connectMore() > DataCenter.php(250): connect() > functions.php(34): dcConnect() > AbstractDriver.php(422): Amp\{closure}() > AbstractDriver.php(558): invokeMicrotasks() > Revolt\EventLoop\Internal\{closure}() > DriverSuspension.php(54): resume() > AbstractDriver.php(422): Revolt\EventLoop\Internal\{closure}() > AbstractDriver.php(612): invokeMicrotasks() > Revolt\EventLoop\Internal\{closure}() > AbstractDriver.php(494): resume() > AbstractDriver.php(549): invokeCallbacks() > Revolt\EventLoop\Internal\{closure}() > AbstractDriver.php(93): resume() > DriverSuspension.php(99): Revolt\EventLoop\Internal\{closure}() > FutureIterator.php(133): suspend() > Future.php(59): consume() > functions.php(151): iterate() > MTProto.php(1343): Amp\Future\await() > MTProto.php(568): connectToAllDcs() > MTProto.php(505): initialize() > API.php(236): __construct() > LoginByPhone.php(98): __construct() > RequestHandler.php(46): handle() > Route.php(358): __invoke() > MiddlewareDispatcher.php(65): handle() > PrepareTeletgramAuthMiddleware.php(37): handle() > MiddlewareDispatcher.php(168): process() > PrepareTelegramRequest.php(47): handle() > MiddlewareDispatcher.php(168): process() > MiddlewareDispatcher.php(65): handle() > Route.php(315): handle() > RouteRunner.php(68): run() > AuthMiddleware.php(87): handle() > MiddlewareDispatcher.php(168): process() > BodyParsingMiddleware.php(64): handle() > MiddlewareDispatcher.php(121): process() > CorsMiddleware.php(155): handle() > MiddlewareDispatcher.php(121): process() > MiddlewareDispatcher.php(65): handle() > App.php(199): handle() > App.php(183): handle() > index.php(24): run()
danog commented 1 year ago

Fixed!