diff --git a/src/Event/Http/FpmHandler.php b/src/Event/Http/FpmHandler.php index 9925779c4..cc8d3e5b1 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) { @@ -78,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(); } @@ -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. */