-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Allow nonstandard close statuses in ManagedWebSocket #83713
Conversation
Add ServiceRestart (1012), TryAgainLater (1013), and BadGateway (1014) to the list of `WebSocketCloseStatus` values and allow them to be used as valid WebSocket close statuses so we don't reject the close and discard the status description. Fixes dotnet#82602
Tagging subscribers to this area: @dotnet/ncl Issue DetailsAdd ServiceRestart (1012), TryAgainLater (1013), and BadGateway (1014) to the list of Fixes Issue #82602 DescriptionThe current implementation of This means that things like Customer ImpactLost information and ragged closing of a web socket when a server-side or proxy closes because of any of the previously rejected values:
RegressionNo TestingAdded test cases for all three to the HttpListenerWebSocketTests.cs file with no regressions found. RiskChanges the public exposed enum of WebSocketCloseStatus.cs adding three new values that were previously not documented. Package authoring signed off?IMPORTANT: If this change touches code that ships in a NuGet package, please make certain that you have added any necessary package authoring and gotten it explicitly reviewed.
|
Thank you for your contribution @IDisposable! However, you cannot add public API without going through the API review process first. I strongly believe the issue can be fixed without adding new enum values, just by casting Also, when adding the tests, could you please add them to the library that you were changing, i.e. System.Net.WebSockets, not to HttpListener? runtime/src/libraries/System.Net.WebSockets/tests/WebSocketCreateTest.cs Lines 153 to 160 in 8fe12bc
|
Reworking this to not use public API changes... PR will follow in |
Replaced by #83827 |
@CarnaViire I reimplemented this PR without changing the public enum. |
Add ServiceRestart (1012), TryAgainLater (1013), and BadGateway (1014) to the list of
WebSocketCloseStatus
values and allow them to be used as valid WebSocket close statuses so we don't reject the close and discard the status description by adding them to the privateIsValueCloseStatus
method switch statement declaring them as validtrue
.Fixes Issue #82602
Description
The current implementation of
ManagedWebSocket
explicitly declares someWebSocketCloseStatus
values as "acceptable" reasons to close the socket. For those, the information status description is extracted and made available. For all other values, the close status is rejected and the closing information is discarded.This means that things like
BadGateway
(1014), orServiceRestart
(1012), orTryAgainLater
(1013) will be declared invalid byManagedWebSocket.IsValidCloseStatus
and thus not handled cleanly even though they could happen after a web socket is completely setup. These codes are documented here as valid server-initiated close reasons.Customer Impact
Lost information and ragged closing of a web socket when a server-side or proxy closes because of any of the previously rejected values:
This codes are documented here and here as IANA registered and in the Mozilla docs
Regression
No
Testing
Added test cases for all three to new WebSocketCloseTests.cs file with no regressions in current tests.
Risk
This does not change the public enum of
WebSocketCloseStatus
as we don't want to invoke public review and the values are not mentioned in the RFC.Package authoring signed off?
N/A