Conversation
WebSocketConnectionHelper only reused the cached WebSocketInstance for a user while it reported isConnected() == true. Since the ping interval added in #6543 makes the connection cycle through a brief disconnected state every 30-60s by design, any caller (ChatActivity, CallActivity, WebsocketConnectionsWorker) asking for the instance during that window got handed a brand new WebSocketInstance instead, orphaning the old one which kept retrying unsupervised in the background. Within a single instance, restartWebSocket() could also be triggered concurrently (from sendMessage, processErrorMessage, closeWebSocket) without cancelling any socket already in flight, and a stale/superseded socket's failure would still force a reconnect of the current one. Both issues together produced the "5-13 parallel sockets" / repeated "Closing previous client ... for session X" churn from #6710. Fixes #6710. Assisted-by: Claude Code:claude-sonnet-5 Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
mahibi
force-pushed
the
bugfix/6710/fixMultipleWebsockets
branch
from
September 20, 2026 16:41
8021b33 to
2295a42
Compare
mahibi
marked this pull request as ready for review
September 20, 2026 16:41
Collaborator
Author
|
/backport to stable-25.0.x |
Contributor
📱 QA build
The QA build installs alongside a released Nextcloud app, so you can keep Downloading the file requires a GitHub account, so open this link on the |
rapterjet2004
approved these changes
Sep 21, 2026
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.
fix #6710
Root cause, two parts:
WebSocketConnectionHelper.getExternalSignalingInstanceForServer() only reused the cached WebSocketInstance for a user when isConnected() == true. The ping interval added in fix(call): detect dead signaling WebSocket connections via ping interval #6543 makes the connection cycle through a brief
disconnected state every 30-60s by design; any caller asking for the socket during that window got a second, independent instance instead of the existing one, orphaning the first — which kept retrying itself,
unsupervised, in the background.
Within a single WebSocketInstance, nothing cancelled an in-flight socket before starting a new one, and a stale/already-superseded socket's failure could still trigger another reconnect of the current one — letting one
real disconnect cascade into several parallel sockets.
Fix:
The Helper now always reuses an existing instance for a user regardless of connection state (it manages its own reconnects). restartWebSocket() now tracks the new socket before tearing down the old one, and closeWebSocket() ignores callbacks from a socket that's already been superseded.
🏁 Checklist
/backport to stable-xx.x🤖 AI (if applicable)