Skip to content

Fix web connection broken by E3DC server protocol update#142

Merged
fsantini merged 2 commits into
fsantini:masterfrom
johannes-bauer:master
Jun 10, 2026
Merged

Fix web connection broken by E3DC server protocol update#142
fsantini merged 2 commits into
fsantini:masterfrom
johannes-bauer:master

Conversation

@johannes-bauer

Copy link
Copy Markdown
Contributor

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.

johannes-bauer and others added 2 commits April 12, 2026 19:56
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>
@fsantini fsantini merged commit 4253027 into fsantini:master Jun 10, 2026
0 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants