Skip to content

fix: reconnect engine websocket and add keepalive ping on idle - #159

Merged
vantoan1511 merged 3 commits into
mainfrom
fix/idle-backend-disconnect
Aug 27, 2026
Merged

fix: reconnect engine websocket and add keepalive ping on idle#159
vantoan1511 merged 3 commits into
mainfrom
fix/idle-backend-disconnect

Conversation

@vantoan1511

Copy link
Copy Markdown
Owner

Summary

Fixes an issue where leaving the application idle caused the Rust engine's WebSocket bridge to Neutralino to silently drop, leaving the frontend UI reactive but unable to receive responses for any backend/Kubernetes actions.

Changes

  • WebSocket Keepalive Ping: Added a 30s interval ping mechanism (PING_INTERVAL_SECS = 30) using tokio::select! in the main message loop in core/engine/src/main.rs and core/engine/src/ipc/bridge.rs to keep TCP connections alive during idle periods.
  • Engine Reconnection Loop: Restructured main.rs into an outer 'reconnect: loop with exponential backoff (1s -> 2s -> 4s -> ... max 30s) to automatically reconnect if the WebSocket connection drops or errors.
  • State Re-broadcasting: Extracted broadcast_engine_ready to re-emit EngineConnected, ClustersUpdated, and ActiveClusterChanged events across reconnects.
  • Kubernetes Watcher Restart: Extracted restart_watchers to cancel stale background watchers and respawn fresh resource watchers/metric pollers with the new WebSocket writer upon reconnect.
  • Unit Tests: Added tests for exponential backoff calculation and ping interval verification in main.rs.

Files Changed

File Action Description
core/engine/src/ipc/bridge.rs Modified Added PING_INTERVAL_SECS constant
core/engine/src/main.rs Modified Implemented reconnect loop, ping keepalive, and helpers

Testing

  • cargo check and cargo test in core (26/26 unit tests passed)
  • npm run type-check (vue-tsc --build) passed with 0 errors
  • npm run lint (eslint) passed with 0 warnings/errors
  • cargo build --release and npm run build production builds succeeded

Related Artifacts

  • Plan: .agents/PRPs/plans/completed/fix-idle-backend-disconnect.plan.md
  • Report: .agents/PRPs/reports/fix-idle-backend-disconnect-report.md

@github-actions github-actions Bot added the fix label Aug 27, 2026
@vantoan1511
vantoan1511 merged commit 2428c7f into main Aug 27, 2026
2 checks passed
@vantoan1511
vantoan1511 deleted the fix/idle-backend-disconnect branch August 27, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant