JooKS-me opened a new issue #2176:
URL: https://github.com/apache/incubator-shenyu/issues/2176
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Current Behavior
Add selector to websocket plugin, then throw JsonSyntaxException.
### Expected Behavior
No exception.
### Steps To Reproduce
1. start admin
2. start bootstrap
3. add selector for websocket plugin.
### Environment
```markdown
ShenYu version(s): latest in master
```
### Debug logs
in bootstarp:
```
2021-09-29 19:56:20 [main] INFO
org.apache.shenyu.bootstrap.ShenyuBootstrapApplication - Starting
ShenyuBootstrapApplication on JooKSdeMacBook-Pro.local with PID 990
(/Users/jooks/shenyu/shenyu-bootstrap/target/classes started by jooks in
/Users/jooks/shenyu)
2021-09-29 19:56:20 [main] INFO
org.apache.shenyu.bootstrap.ShenyuBootstrapApplication - The following profiles
are active: local
2021-09-29 19:56:21 [main] INFO
org.springframework.data.repository.config.RepositoryConfigurationDelegate -
Multiple Spring Data modules found, entering strict repository configuration
mode!
2021-09-29 19:56:21 [main] INFO
org.springframework.data.repository.config.RepositoryConfigurationDelegate -
Bootstrapping Spring Data Redis repositories in DEFAULT mode.
2021-09-29 19:56:21 [main] INFO
org.springframework.data.repository.config.RepositoryConfigurationDelegate -
Finished Spring Data repository scanning in 16ms. Found 0 Redis repository
interfaces.
2021-09-29 19:56:22 [main] INFO
org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver - Exposing
2 endpoint(s) beneath base path '/actuator'
2021-09-29 19:56:22 [main] INFO
org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load
plugin:[global] [org.apache.shenyu.plugin.global.GlobalPlugin]
2021-09-29 19:56:22 [main] INFO
org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load
plugin:[sign] [org.apache.shenyu.plugin.sign.SignPlugin]
2021-09-29 19:56:22 [main] INFO
org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load
plugin:[jwt] [org.apache.shenyu.plugin.jwt.JwtPlugin]
2021-09-29 19:56:22 [main] INFO
org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load
plugin:[waf] [org.apache.shenyu.plugin.waf.WafPlugin]
2021-09-29 19:56:22 [main] INFO
org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load
plugin:[rate_limiter] [org.apache.shenyu.plugin.ratelimiter.RateLimiterPlugin]
2021-09-29 19:56:22 [main] INFO
org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load
plugin:[param_mapping]
[org.apache.shenyu.plugin.param.mapping.ParamMappingPlugin]
2021-09-29 19:56:22 [main] INFO
org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load
plugin:[context_path] [org.apache.shenyu.plugin.context.path.ContextPathPlugin]
2021-09-29 19:56:22 [main] INFO
org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load
plugin:[rewrite] [org.apache.shenyu.plugin.rewrite.RewritePlugin]
2021-09-29 19:56:22 [main] INFO
org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load
plugin:[redirect] [org.apache.shenyu.plugin.redirect.RedirectPlugin]
2021-09-29 19:56:22 [main] INFO
org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load
plugin:[hystrix] [org.apache.shenyu.plugin.hystrix.HystrixPlugin]
2021-09-29 19:56:22 [main] INFO
org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load
plugin:[sentinel] [org.apache.shenyu.plugin.sentinel.SentinelPlugin]
2021-09-29 19:56:22 [main] INFO
org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load
plugin:[resilience4j] [org.apache.shenyu.plugin.resilience4j.Resilience4JPlugin]
2021-09-29 19:56:22 [main] INFO
org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load
plugin:[logging] [org.apache.shenyu.plugin.logging.LoggingPlugin]
2021-09-29 19:56:22 [main] INFO
org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load
plugin:[monitor] [org.apache.shenyu.plugin.monitor.MonitorPlugin]
2021-09-29 19:56:22 [main] INFO
org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load
plugin:[divide] [org.apache.shenyu.plugin.divide.DividePlugin]
2021-09-29 19:56:22 [main] INFO
org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load
plugin:[websocket] [org.apache.shenyu.plugin.websocket.WebSocketPlugin]
2021-09-29 19:56:22 [main] INFO
org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load
plugin:[webClient] [org.apache.shenyu.plugin.httpclient.WebClientPlugin]
2021-09-29 19:56:22 [main] INFO
org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load
plugin:[modifyResponse]
[org.apache.shenyu.plugin.modify.response.ModifyResponsePlugin]
2021-09-29 19:56:22 [main] INFO
org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load
plugin:[paramTransform] [org.apache.shenyu.plugin.base.RpcParamTransformPlugin]
2021-09-29 19:56:22 [main] INFO
org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load
plugin:[tars] [org.apache.shenyu.plugin.tars.TarsPlugin]
2021-09-29 19:56:22 [main] INFO
org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load
plugin:[grpc] [org.apache.shenyu.plugin.grpc.GrpcPlugin]
2021-09-29 19:56:22 [main] INFO
org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load
plugin:[sofa] [org.apache.shenyu.plugin.sofa.SofaPlugin]
2021-09-29 19:56:22 [main] INFO
org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load
plugin:[dubbo] [org.apache.shenyu.plugin.alibaba.dubbo.AlibabaDubboPlugin]
2021-09-29 19:56:22 [main] INFO
org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load
plugin:[response] [org.apache.shenyu.plugin.response.ResponsePlugin]
2021-09-29 19:56:22 [main] INFO
org.apache.shenyu.springboot.starter.sync.data.websocket.WebsocketSyncDataConfiguration
- you use websocket sync shenyu data.......
2021-09-29 19:56:22 [main] INFO
org.apache.shenyu.plugin.sync.data.websocket.WebsocketSyncDataService -
websocket connection is successful.....
2021-09-29 19:56:22 [WebSocketConnectReadThread-36] INFO
org.apache.shenyu.plugin.sync.data.websocket.client.ShenyuWebsocketClient -
handleResult({"groupType":"PLUGIN","eventType":"MYSELF","data":[{"id":"1","name":"sign","role":"authentication","enabled":false},{"id":"2","name":"waf","config":"{\"model\":\"black\"}","role":"authentication","enabled":false},{"id":"3","name":"rewrite","role":"http
process","enabled":false},{"id":"4","name":"rate_limiter","config":"{\"master\":\"mymaster\",\"mode\":\"standalone\",\"url\":\"192.168.1.1:6379\",\"password\":\"abc\"}","role":"fault
tolerance","enabled":false},{"id":"5","name":"divide","config":"{\"multiSelectorHandle\":\"1\",\"multiRuleHandle\":\"0\"}","role":"proxy","enabled":true},{"id":"6","name":"dubbo","config":"{\"register\":\"zookeeper://localhost:2181\",\"multiSelectorHandle\":\"1\"}","role":"proxy","enabled":false},{"id":"7","name":"monitor","config":"{\"metricsName\":\"prometheus\",\"host\":\"localhost\",\"port\":\"9190\",\"as
ync\":\"true\"}","role":"monitor","enabled":false},{"id":"8","name":"springCloud","role":"proxy","enabled":false},{"id":"9","name":"hystrix","role":"fault
tolerance","enabled":false},{"id":"10","name":"sentinel","role":"fault
tolerance","enabled":false},{"id":"11","name":"sofa","config":"{\"protocol\":\"zookeeper\",\"register\":\"127.0.0.1:2181\"}","role":"proxy","enabled":false},{"id":"12","name":"resilience4j","role":"fault
tolerance","enabled":false},{"id":"13","name":"tars","config":"{\"multiSelectorHandle\":\"1\",\"multiRuleHandle\":\"0\"}","role":"proxy","enabled":false},{"id":"14","name":"context_path","role":"http
process","enabled":true},{"id":"15","name":"grpc","config":"{\"multiSelectorHandle\":\"1\",\"multiRuleHandle\":\"0\"}","role":"proxy","enabled":false},{"id":"16","name":"redirect","role":"http
process","enabled":false},{"id":"17","name":"motan","config":"{\"register\":\"127.0.0.1:2181\"}","role":"proxy","enabled":false},{"id":"18","name":"logging","role":"logging",
"enabled":false},{"id":"19","name":"jwt","config":"{\"secretKey\":\"key\",\"filterPath\":\"\"}","role":"authentication","enabled":false},{"id":"20","name":"request","role":"http
process","enabled":false},{"id":"21","name":"oauth2","role":"authentication","enabled":false},{"id":"22","name":"param_mapping","config":"{\"ruleHandlePageType\":\"custom\"}","role":"http
process","enabled":false},{"id":"23","name":"modifyResponse","config":"{\"ruleHandlePageType\":\"custom\"}","role":"http
process","enabled":false},{"id":"24","name":"cryptor_request","role":"cryptor","enabled":true},{"id":"25","name":"cryptor_response","role":"cryptor","enabled":true},{"id":"26","name":"websocket","role":"proxy","enabled":true}]})
2021-09-29 19:56:22 [WebSocketConnectReadThread-36] INFO
org.apache.shenyu.plugin.sync.data.websocket.client.ShenyuWebsocketClient -
handleResult({"groupType":"SELECTOR","eventType":"MYSELF","data":[]})
2021-09-29 19:56:22 [WebSocketConnectReadThread-36] INFO
org.apache.shenyu.plugin.sync.data.websocket.client.ShenyuWebsocketClient -
handleResult({"groupType":"RULE","eventType":"MYSELF","data":[]})
2021-09-29 19:56:23 [main] INFO
org.springframework.boot.web.embedded.netty.NettyWebServer - Netty started on
port(s): 9195
2021-09-29 19:56:23 [main] INFO
org.apache.shenyu.bootstrap.ShenyuBootstrapApplication - Started
ShenyuBootstrapApplication in 3.419 seconds (JVM running for 4.825)
2021-09-29 19:56:56 [WebSocketConnectReadThread-36] INFO
org.apache.shenyu.plugin.sync.data.websocket.client.ShenyuWebsocketClient -
handleResult({"groupType":"SELECTOR","eventType":"UPDATE","data":[{"id":"1443183007156080640","pluginId":"26","pluginName":"websocket","name":"/websocket","matchMode":0,"type":1,"sort":1,"enabled":true,"logged":true,"continued":true,"handle":"{\"host\":\"localhost:8848\",\"timestamp\":0,\"weight\":50,\"warmup\":0,\"status\":true}","conditionList":[{"paramType":"uri","operator":"\u003d","paramName":"/","paramValue":"/websocket"}]}]})
2021-09-29 19:57:47 [WebSocketConnectReadThread-36] ERROR
org.java_websocket.drafts.Draft_6455 - Runtime exception during
onWebsocketMessage
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException:
Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $
at com.google.gson.Gson.fromJson(Gson.java:899)
at com.google.gson.Gson.fromJson(Gson.java:852)
at com.google.gson.Gson.fromJson(Gson.java:801)
at org.apache.shenyu.common.utils.GsonUtils.fromList(GsonUtils.java:157)
at
org.apache.shenyu.plugin.websocket.handler.WebSocketPluginDataHandler.handlerSelector(WebSocketPluginDataHandler.java:48)
at
org.apache.shenyu.plugin.base.cache.CommonPluginDataSubscriber.lambda$null$3(CommonPluginDataSubscriber.java:155)
at java.util.Optional.ifPresent(Optional.java:159)
at
org.apache.shenyu.plugin.base.cache.CommonPluginDataSubscriber.lambda$subscribeDataHandler$7(CommonPluginDataSubscriber.java:155)
at java.util.Optional.ifPresent(Optional.java:159)
at
org.apache.shenyu.plugin.base.cache.CommonPluginDataSubscriber.subscribeDataHandler(CommonPluginDataSubscriber.java:141)
at
org.apache.shenyu.plugin.base.cache.CommonPluginDataSubscriber.onSelectorSubscribe(CommonPluginDataSubscriber.java:96)
at java.util.ArrayList.forEach(ArrayList.java:1259)
at
org.apache.shenyu.plugin.sync.data.websocket.handler.SelectorDataHandler.doUpdate(SelectorDataHandler.java:50)
at
org.apache.shenyu.plugin.sync.data.websocket.handler.AbstractDataHandler.handle(AbstractDataHandler.java:72)
at
org.apache.shenyu.plugin.sync.data.websocket.handler.WebsocketDataHandler.executor(WebsocketDataHandler.java:59)
at
org.apache.shenyu.plugin.sync.data.websocket.client.ShenyuWebsocketClient.handleResult(ShenyuWebsocketClient.java:94)
at
org.apache.shenyu.plugin.sync.data.websocket.client.ShenyuWebsocketClient.onMessage(ShenyuWebsocketClient.java:74)
at
org.java_websocket.client.WebSocketClient.onWebsocketMessage(WebSocketClient.java:591)
at
org.java_websocket.drafts.Draft_6455.processFrameText(Draft_6455.java:885)
at
org.java_websocket.drafts.Draft_6455.processFrame(Draft_6455.java:819)
at org.java_websocket.WebSocketImpl.decodeFrames(WebSocketImpl.java:379)
at org.java_websocket.WebSocketImpl.decode(WebSocketImpl.java:216)
at
org.java_websocket.client.WebSocketClient.run(WebSocketClient.java:508)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was
BEGIN_OBJECT at line 1 column 2 path $
at com.google.gson.stream.JsonReader.beginArray(JsonReader.java:350)
at
com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:80)
at
com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
at com.google.gson.Gson.fromJson(Gson.java:887)
... 23 common frames omitted
2021-09-29 19:57:52 [shenyu-websocket-connect-1] INFO
org.apache.shenyu.plugin.sync.data.websocket.WebsocketSyncDataService -
websocket reconnect server[ws://localhost:9095/websocket] is successful.....
```
### Anything else?
The code in `WebSocketPluginDataHandler#handlerSelector` should be changed,
or related code in `shenyu-dashboard` should be.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]