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

Set default H2 session timeout #1206

Closed
AllanZhengYP opened this issue May 27, 2020 · 5 comments · Fixed by #3577
Closed

Set default H2 session timeout #1206

AllanZhengYP opened this issue May 27, 2020 · 5 comments · Fixed by #3577
Labels
feature-request New feature or enhancement. May require GitHub community feedback. High Priority

Comments

@AllanZhengYP
Copy link
Contributor

AllanZhengYP commented May 27, 2020

Is your feature request related to a problem? Please describe.
If a service supports H2, the client will contain an H2 request handler by default (i.e. kinesis, but current released client-kinesis uses H1 request handler still). If user make a request, the process doesn't return after the request is completed, unless the request handler is explicitly destroyed.

This is because the H2 request creates an H2 session everytime it establish an H2 connection. Since the connection doesn't close even in idle, the process doesn't return either.

It brings the problem that:

  1. If someone spawn a process calling a Kinesis API, the process will hang there indefinitely after the API call is completed.
  2. If an H1 service later release H2 support, SDK will use H2 http handler accross the service. It would be a breaking change if we ask users to destroy the handler later.

Describe the solution you'd like
Nodejs provides a setTimeout() config on H2 session object. It configs the session to be closed after a certain period of time if it's inactive. By default, there's no timeout.(It has 3 mins default timeout in reality because NginX has default 3 mins idle time)

I suggest the default value to be shorter than 3 mins so it won't hang users process meaninglessly for too long. The defautl value should be longer than couple of seconds otherwise we are losing the benefit of H2.

/cc @trivikr @alexforsyth

@AllanZhengYP AllanZhengYP added feature-request New feature or enhancement. May require GitHub community feedback. High Priority labels May 27, 2020
@AllanZhengYP
Copy link
Contributor Author

Nodejs introduced default timeout of 120 seconds on H2 server timeout very early on but reverted in nodejs/node#27558, because it introduced a lot surprice when it closes the connection unexpectedly.

@github-actions
Copy link

Greetings! We’re closing this issue because it has been open a long time and hasn’t been updated in a while and may not be getting the attention it deserves. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to comment or open a new issue.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label May 28, 2021
@TysonAndre
Copy link
Contributor

Another reason to add a session timeout is #1525 (comment) - clients would get an unexpected error if a load balancer silently drops an inactive HTTP/2 connection without closing it.

It seems like many load balancers hosted by AWS services have a (configurable) default timeout of 300 seconds (after which many silently drop the connection), so my personal preference would be a value less than 300 seconds (such as 120 seconds)

@github-actions github-actions bot removed the closing-soon This issue will automatically close in 4 days unless further comments are made. label May 29, 2021
@trivikr
Copy link
Member

trivikr commented Jul 7, 2021

Nodejs introduced default timeout of 120 seconds on H2 server timeout very early on but reverted in nodejs/node#27558,

The revert in Node.js was done as it was surprising and problematic for users.
The behavior is not common in other language runtimes.

We should not add a default session time out as:

  • It would be backward incompatible. The users on previous versions of 3.x SDK will see their Http2 sessions timing out.
  • The users can always provide their own sessionTimeout as follows:
    const client = new ClientUsingH2Handler({
      requestHandler: new NodeHttp2Handler({
        sessionTimeout: 120000
      }),
    });

Another reason to add a session timeout is #1525 (comment) - clients would get an unexpected error if a load balancer silently drops an inactive HTTP/2 connection without closing it.

Should this be handled by listening to timeout event instead?

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request New feature or enhancement. May require GitHub community feedback. High Priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants