Skip to content

fix(kvm): close browser websocket immediately on AMT disconnect#820

Open
nmgaston wants to merge 2 commits intodevice-management-toolkit:mainfrom
nmgaston:fixKVMNotShowingDisconnected
Open

fix(kvm): close browser websocket immediately on AMT disconnect#820
nmgaston wants to merge 2 commits intodevice-management-toolkit:mainfrom
nmgaston:fixKVMNotShowingDisconnected

Conversation

@nmgaston
Copy link
Contributor

@nmgaston nmgaston commented Mar 3, 2026

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 ListenToBrowser unblocked from its ReadMessage call, 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 websocket CloseMessage to 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 for ListenToBrowser to unblock.

Changes

  • internal/usecase/devices/interceptor.go — updated the ListenToDevice defer to send websocket.CloseMessage and call Close() on the browser connection before cancel()
  • internal/usecase/devices/interceptor_private_test.go — added TestListenToDeviceClosesWebSocketOnAMTDisconnect to verify WriteMessage(CloseMessage) and Close() are called on the browser websocket when the AMT side disconnects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Console UI does not reflect KVM disconnect after AMT closes idle session (~3 minutes inactivity)

1 participant