Fix missing disconnection notifications for invalid close frames - #161
Merged
Merged
Conversation
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.
When ClientWebSocket rejects a close frame such as status 1100, it can enter a closed state before ReceiveAsync throws. The socket-state guard then suppresses DisconnectionHappened, leaving applications unaware of the lost connection.
Report receive failures as a single Lost notification with the original exception. Track whether the receive loop already published a server-close notification so normal closes and CancelClosing do not emit duplicates, while preserving CancelReconnection.
Adds seven regression cases using a real ClientWebSocket and a loopback server that sends raw close frames. Before the fix, the three invalid-close cases failed; the four valid-close cases passed. The existing fake-message test now waits for the server greeting before injecting messages, removing its dependency on receive-loop scheduling.
Validation:
dotnet test Websocket.Client.sln --no-restore --verbosity quiet— 58 passed (52 main tests and 6 integration tests).dotnet build Websocket.Client.sln --configuration Release --verbosity quiet— succeeded with zero warnings or errors, including all seven library targets.75efedb: Linux build and all 58 tests; Windows .NET Framework sample and benchmark builds.Closes #160.