fix(websocket): auto-restart after abnormal local close (pong timeout)#231
Open
krasnyt wants to merge 1 commit into
Open
fix(websocket): auto-restart after abnormal local close (pong timeout)#231krasnyt wants to merge 1 commit into
krasnyt wants to merge 1 commit into
Conversation
When the miniserver stops answering websocket pings, the underlying Java-WebSocket ConnectionLostChecker closes the socket locally with code 1006 (ABNORMAL_CLOSE). onClose() only scheduled an auto-restart when remote == true, so this "frozen connection" case never reconnected even with autoRestart enabled, leaving the connection dead until the app was restarted manually. Also trigger autoRestart() on an abnormal local close (1006). A deliberate LoxoneWebSocket.close() produces a NORMAL (1000) local close, so intentional shutdowns remain excluded.
Author
|
hi @jimirocks , would you have time to have a look? thanks! |
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.
Problem
With
setAutoRestart(true)the client fails to reconnect when the miniserver stops responding to websocket pings (a "frozen" connection). The connection stays dead until the application is restarted manually, even though auto-restart is enabled.Root cause
When the remote end stops answering pongs, the underlying Java-WebSocket
ConnectionLostCheckercloses the socket locally with code1006(ABNORMAL_CLOSE):In
LoxoneWebsocketClient.onClose()the restart is gated behindremote == true:A clean remote close (
1000) recovers fine, but a1006local close — the most common real "frozen connection" case — never schedules a restart.Fix
Also restart on an abnormal local close (
1006):A deliberate
LoxoneWebSocket.close()goes throughcloseBlocking()and produces aNORMAL(1000) local close, so intentional shutdowns are still excluded and won't trigger a restart.Tests
LoxoneWebsocketClientTestnow covers three cases: