Frontmatter
| id | 8177 |
| title | Harden WebSocket Connection: Backoff & Auto-Reconnect |
| state | Closed |
| labels | enhancementaicore |
| assignees | tobiu |
| createdAt | Dec 28, 2025, 6:57 PM |
| updatedAt | Dec 28, 2025, 7:16 PM |
| githubUrl | https://github.com/neomjs/neo/issues/8177 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | 8169 |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Dec 28, 2025, 7:16 PM |
Harden WebSocket Connection: Backoff & Auto-Reconnect
tobiu added parent issue #8169 on Dec 28, 2025, 6:58 PM
tobiu assigned to @tobiu on Dec 28, 2025, 6:59 PM

tobiu
Dec 28, 2025, 7:15 PM
Input from Gemini 3 Pro Preview:
✦ Implementation Complete
I have hardened the WebSocket connection logic to ensure robustness and self-healing capabilities.
Key Improvements:
Configurable Backoff Strategy: Added
backoffStrategytostatic config.
- Default: Exponential backoff
Math.min(1000 * Math.pow(2, attempt - 1), 30000)(1s, 2s, 4s... max 30s).- Overridable: Can be customized globally via
Neo.overwritesor per-instance.Robust Cleanup:
- Replaced standard
setTimeoutwithawait this.timeout(). This leveragesNeo.core.Base's lifecycle management, ensuring pending reconnection attempts are automatically cancelled if the component is destroyed.- Added a safety check
!me.isDestroyedafter the timeout resolves.Self-Healing:
onOpen: ResetsreconnectAttemptsto 0, providing a fresh retry budget for future disconnects.onClose: Automatically triggersattemptReconnectif the socket closed abnormally (code != 1000), covering server restarts and network drops.Observability:
- Added
reconnectingevent (payload:{attempt, maxAttempts, delay}).- Added
reconnect_failedevent.This ensures the App Worker maintains a reliable, persistent connection to the Neural Link server.
tobiu closed this issue on Dec 28, 2025, 7:16 PM
Hardening the WebSocket connection logic is critical for the Neural Link's stability, especially for self-healing scenarios.
Requirements:
attemptReconnectto prevent server flooding.reconnectAttemptsis reset to 0 upon a successful connection (onOpen).reconnectingandreconnect_failedevents for better observability.onClosewith code != 1000), even if no message is being sent.Target File:
src/data/connection/WebSocket.mjsGoal: Make the WebSocket connection resilient to network blips and server restarts, ensuring the App Worker reliably stays connected to the Neural Link.