fix(link-ws): prevent accept_task from exiting on handshake failure#2622
Open
cyanyang-84 wants to merge 1 commit into
Open
fix(link-ws): prevent accept_task from exiting on handshake failure#2622cyanyang-84 wants to merge 1 commit into
cyanyang-84 wants to merge 1 commit into
Conversation
The accept_task loop in zenoh-link-ws would permanently terminate if accept_async returned an error during the initial WebSocket handshake. This occurs when a non-WebSocket request (e.g., standard HTTP GET) is sent to the WebSocket port, leading to a TCP RST for all subsequent clients until the service is restarted. This patch replaces the fatal '?' operator with an explicit match statement. Handshake errors are now traced and the loop continues, ensuring listener resilience similar to QUIC and TLS transports. Validation: Tested with curl to trigger protocol error; listener remained active for subsequent valid connections. Signed-off-by: Cyan Yang <cc.cyan.yang@gmail.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.
Description
What does this PR do?
?operator with an explicitmatchstatement during the WebSocket handshake inio/zenoh-links/zenoh-link-ws/src/unicast.rs.continuestatement instead of terminating theaccept_taskloop.curl) to the WS port. Previously, this killed the listener; with this fix, the listener survives and continues to serve valid WebSocket clients.Why is this change needed?
In
zenoh-link-ws, theaccept_taskloop would permanently terminate ifaccept_asyncreturned an error during the initial WebSocket handshake. This commonly occurs when a non-WebSocket request (like a standard HTTP GET/REST request or a security scanner) is sent to the Zenoh WebSocket port.When this task terminates, the Zenoh router stops accepting any further connections on that specific WebSocket listener, resulting in a TCP RST for all subsequent clients until the service is restarted. This fix ensures the listener remains resilient against invalid connection attempts, similar to existing protections in QUIC and TLS transports.
Related Issues
Related to the fixes in PR #2429 and PR #2432 .
🏷️ Label-Based Checklist
No specific label requirements detected.
Current labels: No labels
Add one of these labels to this PR to see relevant checklist items:
api-sync,breaking-change,bug,ci,dependencies,documentation,enhancement,new feature,internalThis section updates automatically when labels change.