From 682e072a177bb2c0d420c84e74815d058d67e2a7 Mon Sep 17 00:00:00 2001 From: Alexander Pankratov Date: Sat, 18 May 2024 19:18:33 +0200 Subject: [PATCH] Fix: timeout for outgoing messages & possible fatal error for media downloads --- src/MTProtoSession/AckHandler.php | 3 ++- src/MTProtoTools/Files.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/MTProtoSession/AckHandler.php b/src/MTProtoSession/AckHandler.php index 5b6c3f696..f69423a85 100644 --- a/src/MTProtoSession/AckHandler.php +++ b/src/MTProtoSession/AckHandler.php @@ -98,7 +98,7 @@ trait AckHandler { $settings = $this->shared->getSettings(); $global = $this->shared->getGenericSettings(); - $dropTimeout = $global->getRpc()->getRpcDropTimeout(); + $dropTimeout = (int)($global->getRpc()->getRpcDropTimeout() * 1_000_000_000.0); $timeout = (int) ($settings->getTimeout() * 1_000_000_000.0); $pfs = $global->getAuth()->getPfs(); $unencrypted = !$this->shared->hasTempAuthKey(); @@ -122,6 +122,7 @@ trait AckHandler continue; } if ($message->getSent() + $dropTimeout < hrtime(true)) { + Logger::log('No reply for message: ' . $message, Logger::WARNING); $this->handleReject($message, static fn () => new TimeoutException('Request timeout')); continue; } diff --git a/src/MTProtoTools/Files.php b/src/MTProtoTools/Files.php index d418eb68d..d4c67fbdd 100644 --- a/src/MTProtoTools/Files.php +++ b/src/MTProtoTools/Files.php @@ -1140,10 +1140,10 @@ trait Files foreach ($params as $key => $param) { $cancellation?->throwIfRequested(); $param['previous_promise'] = $previous_promise; - $previous_promise = async($this->downloadPart(...), $messageMedia, $cdn, $datacenter, $old_dc, $ige, $cb, $param, $callable, $seekable, $cancellation); + $previous_promise = async($this->downloadPart(...), $messageMedia, $cdn, $datacenter, $old_dc, $ige, $cb, $param, $callable, $seekable, $cancellation)->ignore(); $previous_promise->map(static function (int $res) use (&$size): void { $size += $res; - }); + })->ignore(); $promises[] = $previous_promise; if (\count($promises) === $parallel_chunks) { // 20 mb at a time, for a typical bandwidth of 1gbps