Fix web connection broken by E3DC server protocol update#142
Merged
Conversation
The E3DC server updated its WebSocket protocol in three ways that broke the web connection path: 1. The server now opens the handshake with RSCP_REQ_SET_PROTOCOL_VERSION before SERVER_REGISTER_CONNECTION. Without a reply the server sends SERVER_UNREGISTER_CONNECTION and drops the connection. Handle this message by echoing back RSCP_SET_PROTOCOL_VERSION with the same type and version value the server sent. 2. After the protocol-version exchange the server switches to a compact frame format (ctrl bit 1 set) that omits the 12-byte timestamp and uses a 32-bit length field, giving an 8-byte header instead of 18. rscpFrameDecode now detects ctrl & 0x02 and parses accordingly. 3. rscpDecode advanced past a decoded value using the struct format size rather than the length field from the RSCP header. These two values can differ (e.g. in the server's authentication-failure response), causing the parser to misalign and crash on the next tag. Fixed by using headerSize + length for advancement.
Replace the DEBUG_DICT print-based debug mechanism in _rscpLib.py with proper Python logging (logger.debug/warning) so that callers can control output via the standard logging framework. Add logging to _e3dc_rscp_web.py and _e3dc.py for connection lifecycle events, timeouts, and retries. Sensitive fields (SERVER_USER, SERVER_PASSWD) are redacted in debug output. Fix two further web connection issues discovered with the new logging: 1. SERVER_UNREGISTER_CONNECTION was handled by calling self.disconnect(), but the server now sends this message as part of the normal virtual connection handshake (to close the initial connection before registering the virtual one). Removing the disconnect() call allows the subsequent SERVER_REGISTER_CONNECTION to be received. 2. When authentication fails the server returns virtConId=-1. Previously this caused isConnected() to return True (since -1 is not None), and every subsequent request would silently time out. Now virtConId=-1 is detected, logged as an error, and left as None so the connection attempt fails immediately with RequestTimeoutError. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
This solved issue #136 for me.
BTW: I converted print() calls to logger.info()/logger.debug() calls and added more log lines, which helped me (and claude) pin down the problem and which should help diagnose future problems more easily as well.