Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] add max_request_execution_time config to HTTP server #4594

Closed
smortexa opened this issue Jan 29, 2022 · 2 comments
Closed
Labels

Comments

@smortexa
Copy link

smortexa commented Jan 29, 2022

Related to laravel/octane#470.

When the execution time for requests being handled by Octane exceeded from max_execution_time in the octane.php config file, the Octane wouldn't send any response and the request remains in the pending state. According to @sy-records, when the max_execution_time is reached, A SIGKILL signal is sent directly, so it causes no response and requires Swoole support.

It will be good if Swoole adds max_request_execution_time config to the HTTP server like what OpenSwoole added here.

@ValiDrv
Copy link

ValiDrv commented Jan 29, 2022

Maybe it should not kill the process tho.

It would be more useful to have a coroutine max run time ( where it would stop and shutdown the coroutine, not just yield). That could be used as max_request_execution_time

@matyhtf
Copy link
Member

matyhtf commented Apr 14, 2022

This just closes the connection early, but cannot terminate the coroutine that is processing the http request.

You can use php code to implement, set a timer, and close the connection when timeout.

$server->on("Request", function ($req, $resp) {
    $max_request_execution_time = 1000; // 1s
    Swoole\Timer::after($max_request_execution_time, function () use ($resp) {
        $resp->status(504);
        $resp->end();
    });
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants