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

Fix sending end stream in http2 web socket stream #73222

Merged
merged 7 commits into from
Aug 5, 2022

Conversation

greenEkatherine
Copy link
Contributor

Fixes #72301

@ghost
Copy link

ghost commented Aug 2, 2022

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #72301

Author: greenEkatherine
Assignees: -
Labels:

area-System.Net.Http

Milestone: -

@greenEkatherine greenEkatherine added this to the 7.0.0 milestone Aug 2, 2022
Katya Sokolova and others added 2 commits August 2, 2022 17:52
@karelz
Copy link
Member

karelz commented Aug 4, 2022

@stephentoub please can you code review? Thanks!

@@ -1599,7 +1599,7 @@ private async ValueTask<Http2Stream> SendHeadersAsync(HttpRequestMessage request
// Start the write. This serializes access to write to the connection, and ensures that HEADERS
// and CONTINUATION frames stay together, as they must do. We use the lock as well to ensure new
// streams are created and started in order.
await PerformWriteAsync(totalSize, (thisRef: this, http2Stream, headerBytes, endStream: (request.Content == null), mustFlush), static (s, writeBuffer) =>
await PerformWriteAsync(totalSize, (thisRef: this, http2Stream, headerBytes, endStream: (request.Content == null && !http2Stream.ConnectProtocolEstablished), mustFlush), static (s, writeBuffer) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm doing something wrong, or misunderstanding the change, but if I'm reading this correctly and testing the new feature correctly, this check does nothing because ConnectProtocolEstablished is only set after the request has already been sent and a response with a 200 was received.

if (statusCode == 200 && _response.RequestMessage!.IsWebSocketH2Request())
{
ConnectProtocolEstablished = true;
}

Which means every time an HTTP2 WebSocket request is made it will still send the END_STREAM flag.

Did you test this change with Kestrel before merging? Am I holding the feature wrong?

cc @karelz

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I will double check. I tested it with Kestrel but I probably miss to check state on the server side. Using receive before send works so I thought that the end stream flag causes an issue only on established connection. Also connect without end stream is hanging, I should try different approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I have to switch on flush correctly for both connect and send

@ghost ghost locked as resolved and limited conversation to collaborators Sep 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WebSockets over HTTP/2 issues
5 participants