Skip to content

Fix sending end stream in http2 web socket stream - #73222

Merged
greenEkatherine merged 7 commits into
dotnet:mainfrom
greenEkatherine:fix-end-stream-ws-h2
Aug 5, 2022
Merged

greenEkatherine merged 7 commits into
dotnet:mainfrom
greenEkatherine:fix-end-stream-ws-h2

Conversation

@greenEkatherine

Copy link
Copy Markdown
Contributor

Fixes #72301

@ghost ghost added the area-System.Net.Http label Aug 2, 2022
@ghost ghost assigned greenEkatherine Aug 2, 2022
@ghost

ghost commented Aug 2, 2022

Copy link
Copy Markdown

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
Comment thread src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.Http2.cs Outdated
Comment thread src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.Http2.cs Outdated
Comment thread src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.Http2.cs Outdated
Comment thread src/libraries/System.Net.WebSockets.Client/tests/SendReceiveTest.Http2.cs Outdated
Comment thread src/libraries/System.Net.WebSockets.Client/tests/SendReceiveTest.Http2.cs Outdated
Katya Sokolova and others added 2 commits August 2, 2022 17:52
…st.Http2.cs

Co-authored-by: Natalia Kondratyeva <knatalia@microsoft.com>
@karelz

karelz commented Aug 4, 2022

Copy link
Copy Markdown
Member

@stephentoub please can you code review? Thanks!

Comment thread src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.Http2.cs Outdated
Katya Sokolova and others added 2 commits August 5, 2022 11:48
// 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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