Websocket client `isFull=true` can never register: URI report requires a pre-existing selector, but no metadata is ever sent
Description
When using the Spring websocket client (shenyu-spring-boot-starter-client-spring-websocket) in isFull=true mode, the websocket selector is never created in shenyu-admin and the ws route never becomes available. The admin logs an endless 5s retry loop of selectorDO object is null, wait to retry.
The http (springmvc) client in the same isFull mode works, because it publishes both a MetaDataRegisterDTO and a URIRegisterDTO. The websocket client publishes only the URIRegisterDTO, while the admin side never creates a selector from a URI report — it requires the selector to already exist.
Environment
- ShenYu version(s): 2.7.2-SNAPSHOT (master as of 2026-09), same code paths exist in 2.7.0/2.7.1
- Client: Spring Boot 3.5.x (spring-websocket handler endpoints, no
@ShenyuServerEndpointannotations) - Register type:
http(shenyu.register.registerType=http)
Steps to reproduce
- Start shenyu-admin; enable the
websocketplugin (it is enabled by default). - Start a service with
shenyu-spring-boot-starter-client-spring-websocketon the classpath and:
shenyu:
register:
registerType: http
serverLists: http://127.0.0.1:9095
props:
username: admin
password: 123456
client:
websocket:
props:
appName: my-service
contextPath: /my-service
port: 8101
protocol: ws://
isFull: true
- Watch the admin log and the
selectortable for pluginwebsocket.
Actual result: every ~5 s the admin logs
Register exception: cause: doRegister Failed to execute, because selectorDO object is null, wait to retry.
and no row is ever created in selector for plugin websocket. WS handshakes through the gateway fail with {"code":-107,"message":"websocket:Can not find selector..."} (and after a manually pre-created selector, {"code":-102,"message":"websocket:Rule not found!"} until a rule is also created by hand).
Root cause
SpringWebSocketClientEventListener#getBeans— theisFullbranch publishes only aURIRegisterDTOand returns an empty bean map, so no metadata is ever reported:
// shenyu-client-websocket/shenyu-client-spring-websocket/.../SpringWebSocketClientEventListener.java
public Map<String, Object> getBeans(final ApplicationContext context) {
if (Boolean.TRUE.equals(isFull)) {
if (!markRegistered()) {
return Collections.emptyMap();
}
LOG.info("init spring websocket client success with isFull mode");
List<String> namespaceIds = super.getNamespace();
namespaceIds.forEach(namespaceId -> getPublisher().publishEvent(buildURIRegisterDTO(context, Collections.emptyMap(), namespaceId)));
return Collections.emptyMap(); // <-- no MetaDataRegisterDTO ever published
}
...
}
- On the admin side, a URI report updates an existing selector but does not create one:
// shenyu-admin/.../AbstractShenyuClientRegisterServiceImpl.java#doRegisterURI
SelectorDO selectorDO = selectorService.findByNameAndPluginNameAndNamespaceId(selectorName, pluginName, namespaceId);
if (Objects.isNull(selectorDO)) {
throw new ShenyuException("doRegister Failed to execute, because selectorDO object is null, wait to retry.");
}
- The http client's
isFullbranch publishes metadata and URI (the correct pattern) — seeSpringMvcClientEventListener#getBeans(publishEvent(MetaDataRegisterDTO.builder()...)followed bypublishEvent(buildURIRegisterDTO(...))). The websocket client is asymmetric with it.
Since no metadata ever arrives, the selector is never created and the 5 s FallbackRegisterTask retry (unlimited attempts) never converges.
Expected result
isFull=true on the websocket client should create the websocket selector + default rule (context-path based) from a metadata report, and then fill the handle from the URI report — exactly like the springmvc client.
Suggested fix
In SpringWebSocketClientEventListener#getBeans (isFull branch), publish a MetaDataRegisterDTO before the URI report, mirroring SpringMvcClientEventListener:
getPublisher().publishEvent(MetaDataRegisterDTO.builder()
.appName(getAppName())
.contextPath(getContextPath())
.path(contextPath) // registerContextPath creates selector + default rule
.rpcType(RpcTypeEnum.WEB_SOCKET.getName())
.enabled(true)
.namespaceId(namespaceId)
.build());
(Alternatively, doRegisterURI could lazily create the selector + default rule when missing — but aligning the client with the http client's isFull behavior is the smaller, symmetric change.)
Workaround we used
Manually pre-create the websocket selector + rule (admin REST), after which the pending URI report is accepted and the handle is filled with ws://host:port.
Related: #7169 (another registration-path defect found in the same environment: weight-only changes in Nacos delete live upstream rows).
👋 Hello @Aias00
A new issue has been opened by @Chrisp12138:
- Title: Websocket client
isFull=truecan never register: URI report requires a pre-existing selector, but no metadata is ever sent - Link: https://github.com/apache/shenyu/issues/7168
Please review when you have time. Thank you! 🙏
I will fix it
I will fix it