Skip to content

fix(link-ws): prevent accept_task from exiting on handshake failure#2622

Open
cyanyang-84 wants to merge 1 commit into
eclipse-zenoh:mainfrom
cyanyang-84:fix/ws-listener-handshake
Open

fix(link-ws): prevent accept_task from exiting on handshake failure#2622
cyanyang-84 wants to merge 1 commit into
eclipse-zenoh:mainfrom
cyanyang-84:fix/ws-listener-handshake

Conversation

@cyanyang-84

@cyanyang-84 cyanyang-84 commented May 28, 2026

Copy link
Copy Markdown

Description

What does this PR do?

  • Replaces the error-propagating ? operator with an explicit match statement during the WebSocket handshake in io/zenoh-links/zenoh-link-ws/src/unicast.rs.
  • Ensures that handshake failures (e.g., protocol errors) are traced and handled by a continue statement instead of terminating the accept_task loop.
  • Validation: Verified by sending a plain HTTP request (via 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, the accept_task loop would permanently terminate if accept_async returned 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, internal

This section updates automatically when labels change.

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>
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.

1 participant