shenyu icon indicating copy to clipboard operation
shenyu copied to clipboard

WebSocket isFull registration creates an exact-path rule that cannot match endpoint sub-paths

Open Chrisp12138 opened this issue 3 weeks ago • 0 comments

Environment

  • ShenYu versions: 2.7.2 (verified in a live deployment), master (code inspection)
  • Client: shenyu-spring-boot-starter-client-spring-websocket with shenyu.client.websocket.props.isFull=true

Describe the bug

With isFull=true, the websocket client registers metadata whose path is the bare context path:

// SpringWebSocketClientEventListener#getBeans, isFull branch
MetaDataRegisterDTO.builder()
        .contextPath(getContextPath())
        .path(getContextPath())        // exact path, no wildcard
        .ruleName(getContextPath())

shenyu-admin derives the websocket rule pathPattern from this value, so the auto-created rule only matches the context path itself. Any real websocket endpoint below the context path is unreachable through the gateway.

In contrast, the springmvc (divide) client isFull branch registers contextPath + "/**", so HTTP sub-paths work. The websocket client is the odd one out.

Steps to reproduce

  1. Deploy a service with server.servlet.context-path=/data/asset, a websocket endpoint at /ws/access/upload, and shenyu.client.websocket.props.isFull=true.
  2. Observe shenyu-admin auto-create websocket selector /data/asset and rule /data/asset (exact path, no wildcard).
  3. Connect through the gateway: ws://gateway:9195/data/asset/ws/access/upload.
  4. The handshake fails; the bootstrap logs:
websocket selector success match , selector name :/data/asset
can not match rule data: websocket , path is /data/asset/ws/access/upload

Evidence from a live deployment (2026-11-09)

  • selector match: websocket selector success match , selector name :/data/asset
  • rule miss: can not match rule data: websocket , path is /data/asset/ws/access/upload
  • DB rule_condition values: websocket plugin = /data/asset (exact) vs divide plugin = /data/asset/**

Expected behavior

The websocket isFull rule should cover the context path and everything below it (/data/asset/**), consistent with the divide client, so endpoints under the context path are reachable through the gateway.

Suggested fix

Align the websocket isFull metadata path with the divide client idiom:

.path(UriComponentsBuilder.fromUriString(
        PathUtils.decoratorPathWithSlash(getContextPath()) + EVERY_PATH)
        .build().encode().toUriString())

Chrisp12138 avatar Nov 09 '26 06:11 Chrisp12138