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

HttpServer支持请求超时控制 #59

Open
hhxsv5 opened this issue Jul 12, 2019 · 2 comments
Open

HttpServer支持请求超时控制 #59

hhxsv5 opened this issue Jul 12, 2019 · 2 comments

Comments

@hhxsv5
Copy link

hhxsv5 commented Jul 12, 2019

背景

目前在Swoole\Http\Server中每个请求的最大执行时间没有限制,无法终止一些耗时的请求,只有靠上层Nginx配置proxy_read_timeout来间接地取消请求,但这样对客户端不够友好。

提议

希望能增加配置项time_limit来限制每个请求的最大可执行时间(类似于set_time_limit),超时后能有个回调,来动态地给出超时的响应。

$serv->set([
    'time_limit' => 30, // 每个请求的最大执行时间 30s,设置为0表示不限制
    'time_limit_callback' => function(Swoole\Http\Request $request, Swoole\Http\Response $response, $timeLimit) {
        $response->end(sprintf('响应超时:%.1f秒', $timeLimit));
    }
]);
@hhxsv5
Copy link
Author

hhxsv5 commented Jun 29, 2020

@matyhtf @twose 有可能支持吗?

@hhxsv5
Copy link
Author

hhxsv5 commented Nov 1, 2021

有更新吗?

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

No branches or pull requests

1 participant