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

Add options to set h2 keepalive_timeout? #826

Open
taikulawo opened this issue Dec 24, 2024 · 7 comments · May be fixed by #827
Open

Add options to set h2 keepalive_timeout? #826

taikulawo opened this issue Dec 24, 2024 · 7 comments · May be fixed by #827

Comments

@taikulawo
Copy link

We want close non-active connection to avoid fd run out. https://nginx.org/en/docs/http/ngx_http_core_module.html#keepalive_timeout

I can open a PR if you accept.

  1. increment number when there has stream https://github.com/nginx/nginx/blob/43191be96fb5f425710400e0064c0f2d285a352d/src/http/v2/ngx_http_v2.c#L3097
  2. when hit timeout, check whether has stream active, or close h2 connection. https://github.com/nginx/nginx/blob/43191be96fb5f425710400e0064c0f2d285a352d/src/http/v2/ngx_http_v2.c#L629
@taikulawo taikulawo changed the title Is there a way to configure h2 keepalive_timeout? Add options to set h2 keepalive_timeout? Dec 24, 2024
@taikulawo taikulawo linked a pull request Dec 24, 2024 that will close this issue
@seanmonstar
Copy link
Member

h2 doesn't use Tokio's runtime types, like the timer, so that it can be portable to other runtimes.

We could probably scope out how to add it to hyper, which has a generic timer type.

@taikulawo
Copy link
Author

taikulawo commented Dec 24, 2024

But how to add keepalive timeout where we don't rely on hyper, just use h2?

@taikulawo
Copy link
Author

maybe we could find the way without use tokio?

@seanmonstar
Copy link
Member

I think it can be done almost entirely outside of h2. Set up a sleep(), and when it wakes up, check if there's active streams. I think the only thing missing from h2 is some sort of Connection::active_streams() -> usize method.

@taikulawo
Copy link
Author

when sleep wake up? I don't know where to setup sleep.

@taikulawo
Copy link
Author

if timeout is 60s, we should only time start when there no.active streams. but there no callback to me to start

@taikulawo
Copy link
Author

I have implement active prototype

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

Successfully merging a pull request may close this issue.

2 participants