Fix 1850#1862
Merged
Merged
Conversation
…rio#1850) The Twisted WampRawSocketProtocol.abort() guarded on isOpen(), which requires an attached WAMP session. During the opening handshake no session exists yet, so a handshake failure (invalid magic byte from a port scanner / service probe, or no suitable serializer) made abort() take the else-branch and raise TransportLost. That exception escaped through dataReceived into the Twisted reactor and was logged as an "Unhandled Error" with a full stack trace, while the TCP connection stayed open. Fix: - abort() now guards on `self.transport is not None` instead of isOpen(): aborting a transport does not require an open WAMP session, only a transport. A genuinely missing transport still raises TransportLost. Post-handshake callers (stringReceived error paths, _on_handshake_complete) are unaffected, since an open session always has a transport. - The four handshake-failure sites (server/client x bad-magic/ no-serializer) now `return` after abort(). Previously they relied on abort() raising to stop processing; without the return they would fall through and continue the handshake (e.g. write a reply and start a session) on an aborted connection. The asyncio backend already handled this correctly (parse_handshake raises HandshakeError, caught in data_received -> protocol_error closes the transport and returns). Added cross-backend regression tests for both Twisted and asyncio, server and client. Fixes crossbario#1850. Note: abort() is part of ITransport; this changes its behavior in the pre-session state from raising TransportLost to closing the transport. Flagging for careful human review per AI_POLICY.md. Note: This work was completed with AI assistance (Claude Code).
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.
fixes #1850