You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem: I need to create api and some methods I call can take up to 45 seconds to generate a response.
Is there a way to remove or increase timeout.
I copied example with delayed response and increased wait time to 30 seconds.
#!/usr/bin/env php<?phpdeclare(strict_types=1);
require"vendor/autoload.php";
useAmp\ByteStream;
useAmp\Http\HttpStatus;
useAmp\Http\Server\DefaultErrorHandler;
useAmp\Http\Server\Request;
useAmp\Http\Server\RequestHandler\ClosureRequestHandler;
useAmp\Http\Server\Response;
useAmp\Http\Server\SocketHttpServer;
useAmp\Log\ConsoleFormatter;
useAmp\Log\StreamHandler;
useMonolog\Logger;
useMonolog\Processor\PsrLogMessageProcessor;
usefunctionAmp\delay;
usefunctionAmp\trapSignal;
// Run this script, then visit http://localhost:1338/ in your browser.$logHandler = newStreamHandler(ByteStream\getStdout());
$logHandler->pushProcessor(newPsrLogMessageProcessor());
$logHandler->setFormatter(newConsoleFormatter());
$logger = newLogger('server');
$logger->pushHandler($logHandler);
$server = SocketHttpServer::createForDirectAccess($logger);
$server->expose("0.0.0.0:1338");
$server->expose("[::]:1338");
$server->start(newClosureRequestHandler(function (Request$request) use($logger): Response {
// We delay the response here, but this could also be non-blocking I/O.// Further requests are still processed concurrently.delay(30);
$logger->info("End of delay.");
returnnewResponse(HttpStatus::OK, [
"content-type" => "text/plain; charset=utf-8",
], "Hello, World!");
}), newDefaultErrorHandler());
// Await a termination signal to be received.$signal = trapSignal([\SIGHUP, \SIGINT, \SIGQUIT, \SIGTERM]);
$logger->info(sprintf("Received signal %d, stopping HTTP server", $signal));
$server->stop();
And result I get:
$ time curl -m 60 http://127.0.0.1:1338/
curl: (52) Empty reply from server
real 0m14.483s
user 0m0.009s
sys 0m0.006s
The text was updated successfully, but these errors were encountered:
Problem: I need to create api and some methods I call can take up to 45 seconds to generate a response.
Is there a way to remove or increase timeout.
I copied example with delayed response and increased wait time to 30 seconds.
And result I get:
$ time curl -m 60 http://127.0.0.1:1338/ curl: (52) Empty reply from server real 0m14.483s user 0m0.009s sys 0m0.006s
The text was updated successfully, but these errors were encountered: