http: provide keep-alive timeout response header#34561
Closed
ronag wants to merge 3 commits intonodejs:masterfrom
Closed
http: provide keep-alive timeout response header#34561ronag wants to merge 3 commits intonodejs:masterfrom
ronag wants to merge 3 commits intonodejs:masterfrom
Conversation
Member
Author
|
@nodejs/http |
In http 1.1 persistent connection protocol there is a timing race where the client sends the request and then the server kills the connection (due to inactivity) before receiving the client's request. By providing a keep-alive header it is possible to provide the client a hint of when idle timeout would occur and avoid the race. Fixes: nodejs#34560
addaleax
approved these changes
Jul 30, 2020
ronag
commented
Jul 30, 2020
| if (shouldSendKeepAlive) { | ||
| header += 'Connection: keep-alive\r\n'; | ||
| if (this._keepAliveTimeout) { | ||
| const timeoutSeconds = MathFloor(this._keepAliveTimeout) / 1000; |
Member
Author
There was a problem hiding this comment.
Should we always set this to less than the actual timeout? And if so what is a good algorithm?
Member
Author
There was a problem hiding this comment.
Based nodejs/undici#279 I feel that any client should always assume a value less than the hint. So further reducing it here can be counter productive.
Member
Author
|
@nodejs/http @nodejs/web-server-frameworks |
Collaborator
Collaborator
mcollina
approved these changes
Jul 30, 2020
Member
mcollina
left a comment
There was a problem hiding this comment.
lgtm, it would be good if our own agent would do somethign about this as well.
lpinca
approved these changes
Jul 30, 2020
himself65
approved these changes
Jul 30, 2020
rickyes
approved these changes
Jul 31, 2020
trivikr
approved these changes
Jul 31, 2020
rexagod
approved these changes
Jul 31, 2020
Member
Author
|
Landed in 849d9e7 |
ronag
added a commit
that referenced
this pull request
Aug 1, 2020
In http 1.1 persistent connection protocol there is a timing race where the client sends the request and then the server kills the connection (due to inactivity) before receiving the client's request. By providing a keep-alive header it is possible to provide the client a hint of when idle timeout would occur and avoid the race. Fixes: #34560 PR-URL: #34561 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Zeyu Yang <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Pranshu Srivastava <[email protected]>
codebytere
pushed a commit
that referenced
this pull request
Aug 5, 2020
In http 1.1 persistent connection protocol there is a timing race where the client sends the request and then the server kills the connection (due to inactivity) before receiving the client's request. By providing a keep-alive header it is possible to provide the client a hint of when idle timeout would occur and avoid the race. Fixes: #34560 PR-URL: #34561 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Zeyu Yang <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Pranshu Srivastava <[email protected]>
Merged
This was referenced Aug 25, 2020
4 tasks
killagu
reviewed
Sep 7, 2020
| header += 'Connection: keep-alive\r\n'; | ||
| if (this._keepAliveTimeout) { | ||
| const timeoutSeconds = MathFloor(this._keepAliveTimeout) / 1000; | ||
| header += `Keep-Alive: timeout=${timeoutSeconds}\r\n`; |
Contributor
There was a problem hiding this comment.
Not add the header if the Keep-Alive exits maybe better.
This was referenced Sep 8, 2020
rickyes
pushed a commit
that referenced
this pull request
Sep 12, 2020
PR-URL: #35138 Fixes: #34561 Reviewed-By: Ricky Zhou <[email protected]> Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Zeyu Yang <[email protected]>
ruyadorno
pushed a commit
that referenced
this pull request
Sep 17, 2020
PR-URL: #35138 Fixes: #34561 Reviewed-By: Ricky Zhou <[email protected]> Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Zeyu Yang <[email protected]>
addaleax
pushed a commit
that referenced
this pull request
Sep 22, 2020
In http 1.1 persistent connection protocol there is a timing race where the client sends the request and then the server kills the connection (due to inactivity) before receiving the client's request. By providing a keep-alive header it is possible to provide the client a hint of when idle timeout would occur and avoid the race. Fixes: #34560 PR-URL: #34561 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Zeyu Yang <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Pranshu Srivastava <[email protected]>
addaleax
pushed a commit
that referenced
this pull request
Sep 22, 2020
In http 1.1 persistent connection protocol there is a timing race where the client sends the request and then the server kills the connection (due to inactivity) before receiving the client's request. By providing a keep-alive header it is possible to provide the client a hint of when idle timeout would occur and avoid the race. Fixes: #34560 PR-URL: #34561 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Zeyu Yang <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Pranshu Srivastava <[email protected]>
Merged
MylesBorins
pushed a commit
that referenced
this pull request
Nov 3, 2020
Backport-PR-URL: #35623 PR-URL: #35138 Fixes: #34561 Reviewed-By: Ricky Zhou <[email protected]> Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Zeyu Yang <[email protected]>
MylesBorins
pushed a commit
that referenced
this pull request
Nov 16, 2020
Backport-PR-URL: #35623 PR-URL: #35138 Fixes: #34561 Reviewed-By: Ricky Zhou <[email protected]> Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Zeyu Yang <[email protected]>
2 tasks
joesepi
pushed a commit
to joesepi/node
that referenced
this pull request
Jan 8, 2021
PR-URL: nodejs#35138 Fixes: nodejs#34561 Reviewed-By: Ricky Zhou <[email protected]> Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Zeyu Yang <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In http 1.1 persistent connection protocol there is a timing race where the
client sends the request and then the server kills the connection
(due to inactivity) before receiving the client's request.
By providing a keep-alive header it is possible to provide the client a
hint of when idle timeout would occur and avoid the race.
Fixes: #34560
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes