fix(kvm): close browser websocket immediately on AMT disconnect#820
Open
nmgaston wants to merge 2 commits intodevice-management-toolkit:mainfrom
Open
fix(kvm): close browser websocket immediately on AMT disconnect#820nmgaston wants to merge 2 commits intodevice-management-toolkit:mainfrom
nmgaston wants to merge 2 commits intodevice-management-toolkit:mainfrom
Conversation
9ac8e2b to
7361bb8
Compare
4 tasks
6733334 to
5b28824
Compare
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.
NOTE: Use with sample-web-ui PR: device-management-toolkit/sample-web-ui#3159
Problem
When an AMT device disconnects (e.g. the device is powered off or the network drops), the KVM/SOL/IDER session would appear frozen in the browser UI. The browser websocket was only closed after
ListenToBrowserunblocked from itsReadMessagecall, which could take up to 30 seconds (the inactivity timeout) or indefinitely if the browser wasn't sending data.Fix
In
ListenToDevice, the deferred cleanup now immediately sends a websocketCloseMessageto the browser and closes the connection before cancelling the context. This means the browser receives the close frame as soon as the AMT device side drops, allowing the UI to update without waiting forListenToBrowserto unblock.Changes
internal/usecase/devices/interceptor.go— updated theListenToDevicedefer to sendwebsocket.CloseMessageand callClose()on the browser connection beforecancel()internal/usecase/devices/interceptor_private_test.go— addedTestListenToDeviceClosesWebSocketOnAMTDisconnectto verifyWriteMessage(CloseMessage)andClose()are called on the browser websocket when the AMT side disconnects