From 9791c1237775f3b4f348f4cb17927e7ae106f059 Mon Sep 17 00:00:00 2001 From: Deleu Date: Thu, 8 Oct 2020 12:05:22 +0200 Subject: [PATCH 1/2] Allow developer to control FpmHandler timeout --- src/Event/Http/FpmHandler.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Event/Http/FpmHandler.php b/src/Event/Http/FpmHandler.php index 9925779c4..7984ae4c6 100644 --- a/src/Event/Http/FpmHandler.php +++ b/src/Event/Http/FpmHandler.php @@ -43,6 +43,8 @@ final class FpmHandler extends HttpHandler private $configFile; /** @var Process|null */ private $fpm; + /** @var int */ + private $socketReadWriteTimeout = 30000; public function __construct(string $handler, string $configFile = self::CONFIG) { @@ -98,6 +100,17 @@ public function __destruct() $this->stop(); } + /** + * Allow the developer to change the Socket Read Write Timeout to support APIs that take + * longer than 30 seconds to run behing ALB. + */ + public function setSocketReadWriteTimeout(int $timeout): self + { + $this->socketReadWriteTimeout = $timeout; + + return $this; + } + /** * Proxy the API Gateway event to PHP-FPM and return its response. */ From e1d0dc7847995aad6acc1461be4e582f1bd0bc29 Mon Sep 17 00:00:00 2001 From: Deleu Date: Thu, 8 Oct 2020 13:19:12 +0200 Subject: [PATCH 2/2] Forgot to use the variable :sweat_smile: --- src/Event/Http/FpmHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Event/Http/FpmHandler.php b/src/Event/Http/FpmHandler.php index 7984ae4c6..cc8d3e5b1 100644 --- a/src/Event/Http/FpmHandler.php +++ b/src/Event/Http/FpmHandler.php @@ -80,7 +80,7 @@ public function start(): void }); $this->client = new Client; - $this->connection = new UnixDomainSocket(self::SOCKET, 1000, 30000); + $this->connection = new UnixDomainSocket(self::SOCKET, 1000, $this->socketReadWriteTimeout); $this->waitUntilReady(); }