apache / shenyu-helm-chart

Helm Chart for deploying Apache ShenYu in Kubernetes
https://shenyu.apache.org/
Apache License 2.0
15 stars 9 forks source link

WebSocket Connect Error #14

Closed skyleaworlder closed 1 year ago

skyleaworlder commented 1 year ago

I use as:

# tag: shenyu-0.2.0
git clone https://github.com/apache/shenyu-helm-chart
cd charts/shenyu
helm dependency build
helm install shenyu .

and shenyu-bootstrap reports:

2022-09-24 09:43:31 [WebSocketConnectReadThread-31] ERROR org.apache.shenyu.plugin.sync.data.websocket.client.ShenyuWebsocketClient - websocket server[ws://shenyu-admin.shenyu.svc.cluster.local:9095/websocket] is error.....
java.net.ConnectException: Connection refused (Connection refused)
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
        at java.net.Socket.connect(Socket.java:589)
        at org.java_websocket.client.WebSocketClient.run(WebSocketClient.java:461)
        at java.lang.Thread.run(Thread.java:748)

I want to know if I make some mistakes to cause this...

skyleaworlder commented 1 year ago

I also try to run shenyu-admin and shenyu-bootstrap by docker compose:

version: "3.9"

services:
  shenyu-admin:
    image: apache/shenyu-admin:latest
    container_name: shenyu-admin
    restart: always
    networks:
      - shenyu
    ports:
      - "9095:9095"
    environment:
      - SPRING_PROFILES_ACTIVE=h2
      - shenyu.database.init_script=sql-script/h2/schema.sql
    healthcheck:
      test: ["CMD-SHELL", "wget -q -O - http://shenyu-admin:9095/actuator/health | grep UP || exit 1"]
      timeout: 2s
      retries: 30

  shenyu-bootstrap:
    image: apache/shenyu-bootstrap:latest
    container_name: shenyu-bootstrap
    restart: always
    networks:
      - shenyu
    ports:
      - "9195:9195"
    environment:
      - shenyu.sync.websocket.urls=ws://shenyu-admin:9095/websocket

networks:
  shenyu:
    name: shenyu

Finally, shenyu-bootstrap managed by docker compose can build websocket connection with shenyu-admin:

shenyu-bootstrap  | 2022-09-24 10:00:19 [main] INFO  org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load plugin:[tars] [org.apache.shenyu.plugin.tars.TarsPlugin]
shenyu-bootstrap  | 2022-09-24 10:00:19 [main] INFO  org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load plugin:[dubbo] [org.apache.shenyu.plugin.apache.dubbo.ApacheDubboPlugin]
shenyu-bootstrap  | 2022-09-24 10:00:19 [main] INFO  org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load plugin:[motan] [org.apache.shenyu.plugin.motan.MotanPlugin]
shenyu-bootstrap  | 2022-09-24 10:00:19 [main] INFO  org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load plugin:[grpc] [org.apache.shenyu.plugin.grpc.GrpcPlugin]
shenyu-bootstrap  | 2022-09-24 10:00:19 [main] INFO  org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load plugin:[cryptorResponse] [org.apache.shenyu.plugin.cryptor.response.CryptorResponsePlugin]
shenyu-bootstrap  | 2022-09-24 10:00:19 [main] INFO  org.apache.shenyu.springboot.starter.gateway.ShenyuConfiguration - load plugin:[response] [org.apache.shenyu.plugin.response.ResponsePlugin]
shenyu-bootstrap  | 2022-09-24 10:00:19 [main] INFO  org.apache.shenyu.springboot.starter.sync.data.websocket.WebsocketSyncDataConfiguration - you use websocket sync shenyu data.......
shenyu-bootstrap  | 2022-09-24 10:00:19 [WebSocketConnectReadThread-27] ERROR org.apache.shenyu.plugin.sync.data.websocket.client.ShenyuWebsocketClient - websocket server[ws://shenyu-admin:9095/websocket] is error.....
shenyu-bootstrap  | java.net.ConnectException: Connection refused (Connection refused)
shenyu-bootstrap  |     at java.net.PlainSocketImpl.socketConnect(Native Method)
shenyu-bootstrap  |     at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
shenyu-bootstrap  |     at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
shenyu-bootstrap  |     at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
shenyu-bootstrap  |     at java.net.Socket.connect(Socket.java:589)
shenyu-bootstrap  |     at org.java_websocket.client.WebSocketClient.run(WebSocketClient.java:461)
shenyu-bootstrap  |     at java.lang.Thread.run(Thread.java:748)
shenyu-bootstrap  | 2022-09-24 10:00:19 [main] WARN  org.apache.shenyu.plugin.sync.data.websocket.client.ShenyuWebsocketClient - websocket connection server[ws://shenyu-admin:9095/websocket] is error.....
shenyu-bootstrap  | 2022-09-24 10:00:20 [main] INFO  org.springframework.cloud.netflix.eureka.config.DiscoveryClientOptionalArgsConfiguration - Eureka HTTP Client uses RestTemplate.
shenyu-bootstrap  | 2022-09-24 10:00:21 [main] INFO  org.springframework.boot.web.embedded.netty.NettyWebServer - Netty started on port 9195
shenyu-bootstrap  | 2022-09-24 10:00:21 [main] INFO  org.apache.shenyu.bootstrap.ShenyuBootstrapApplication - Started ShenyuBootstrapApplication in 19.335 seconds (JVM running for 20.913)
shenyu-admin      | 2022-09-24 10:00:22 [main] INFO  org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - Inconsistent constructor declaration on bean with name 'httpServiceDiscovery': single autowire-marked constructor flagged as optional - this constructor is effectively required since there is no default 
constructor to fall back to: public org.apache.shenyu.admin.listener.zookeeper.HttpServiceDiscovery(org.apache.shenyu.admin.service.SelectorService,org.apache.shenyu.admin.mapper.SelectorMapper,org.springframework.context.ApplicationEventPublisher,org.springframework.core.env.Environment)
shenyu-admin      | 2022-09-24 10:00:23 [main] INFO  org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver - Exposing 1 endpoint(s) beneath base path '/actuator'
shenyu-admin      | 2022-09-24 10:00:23 [main] INFO  springfox.documentation.spring.web.PropertySourcedRequestMappingHandlerMapping - Mapped URL path [/v2/api-docs] onto 
method [springfox.documentation.swagger2.web.Swagger2Controller#getDocumentation(String, HttpServletRequest)]
shenyu-admin      | 2022-09-24 10:00:23 [main] INFO  org.springframework.boot.autoconfigure.web.servlet.WelcomePageHandlerMapping - Adding welcome page: class path resource [static/index.html]
shenyu-admin      | 2022-09-24 10:00:25 [main] INFO  org.apache.coyote.http11.Http11NioProtocol - Starting ProtocolHandler ["http-nio-0.0.0.0-9095"]
shenyu-admin      | 2022-09-24 10:00:25 [main] INFO  org.springframework.boot.web.embedded.tomcat.TomcatWebServer - Tomcat started on port(s): 9095 (http) with context path ''
shenyu-admin      | 2022-09-24 10:00:25 [main] INFO  org.apache.shenyu.admin.service.manager.impl.LoadServiceDocEntryImpl - getAllClusterLastUpdateInstanceList, Not loaded into available backend services.
shenyu-admin      | 2022-09-24 10:00:25 [main] INFO  org.apache.shenyu.admin.service.manager.impl.LoadServiceDocEntryImpl - load api document No service registered.      
shenyu-admin      | 2022-09-24 10:00:25 [main] INFO  springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper - Context refreshed
shenyu-admin      | 2022-09-24 10:00:25 [main] INFO  springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper - Found 1 custom documentation plugin(s) 
shenyu-admin      | 2022-09-24 10:00:25 [main] INFO  springfox.documentation.spring.web.scanners.ApiListingReferenceScanner - Scanning for api listing references
shenyu-admin      | 2022-09-24 10:00:25 [main] INFO  springfox.documentation.spring.web.readers.operation.CachingOperationNameGenerator - Generating unique operation named: detailUsingGET_1
shenyu-admin      | 2022-09-24 10:00:25 [main] INFO  springfox.documentation.spring.web.readers.operation.CachingOperationNameGenerator - Generating unique operation named: batchEnabledUsingPOST_1
shenyu-admin      | 2022-09-24 10:00:25 [main] INFO  springfox.documentation.spring.web.readers.operation.CachingOperationNameGenerator - Generating unique operation named: detailUsingGET_2
shenyu-admin      | 2022-09-24 10:00:25 [main] INFO  springfox.documentation.spring.web.readers.operation.CachingOperationNameGenerator - Generating unique operation named: syncDataUsingPOST_1
shenyu-admin      | 2022-09-24 10:00:26 [main] INFO  springfox.documentation.spring.web.readers.operation.CachingOperationNameGenerator - Generating unique operation named: searchUsingPOST_1
shenyu-admin      | 2022-09-24 10:00:26 [main] INFO  springfox.documentation.spring.web.readers.operation.CachingOperationNameGenerator - Generating unique operation named: searchAdaptorUsingPOST_1
shenyu-admin      | 2022-09-24 10:00:26 [main] INFO  springfox.documentation.spring.web.readers.operation.CachingOperationNameGenerator - Generating unique operation named: searchUsingPOST_2
shenyu-admin      | 2022-09-24 10:00:26 [main] INFO  springfox.documentation.spring.web.readers.operation.CachingOperationNameGenerator - Generating unique operation named: searchAdaptorUsingPOST_2
shenyu-admin      | 2022-09-24 10:00:26 [main] INFO  springfox.documentation.spring.web.readers.operation.CachingOperationNameGenerator - Generating unique operation named: detailRuleUsingGET_1
shenyu-admin      | 2022-09-24 10:00:26 [main] INFO  springfox.documentation.spring.web.readers.operation.CachingOperationNameGenerator - Generating unique operation named: searchUsingPOST_3
shenyu-admin      | 2022-09-24 10:00:26 [main] INFO  springfox.documentation.spring.web.readers.operation.CachingOperationNameGenerator - Generating unique operation named: searchAdaptorUsingPOST_3
shenyu-admin      | 2022-09-24 10:00:26 [main] INFO  springfox.documentation.spring.web.readers.operation.CachingOperationNameGenerator - Generating unique operation named: deleteSelectorUsingDELETE_1
shenyu-admin      | 2022-09-24 10:00:26 [main] INFO  springfox.documentation.spring.web.readers.operation.CachingOperationNameGenerator - Generating unique operation named: searchUsingPOST_4
shenyu-admin      | 2022-09-24 10:00:26 [main] INFO  springfox.documentation.spring.web.readers.operation.CachingOperationNameGenerator - Generating unique operation named: searchAdaptorUsingPOST_4
shenyu-admin      | 2022-09-24 10:00:26 [main] INFO  springfox.documentation.spring.web.readers.operation.CachingOperationNameGenerator - Generating unique operation named: batchEnabledUsingPOST_2
shenyu-admin      | 2022-09-24 10:00:26 [main] INFO  springfox.documentation.spring.web.readers.operation.CachingOperationNameGenerator - Generating unique operation named: detailUsingGET_3
shenyu-admin      | 2022-09-24 10:00:26 [main] INFO  org.apache.shenyu.admin.ShenyuAdminBootstrap - Started ShenyuAdminBootstrap in 25.941 seconds (JVM running for 26.469)
shenyu-admin      | 2022-09-24 10:00:27 [main] WARN  org.apache.shenyu.admin.utils.SessionUtil - get user info error ,not found, used default user ,it unknown
shenyu-admin      | 2022-09-24 10:00:29 [http-nio-0.0.0.0-9095-exec-1] INFO  org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/] - Initializing Spring DispatcherServlet 'dispatcherServlet'
shenyu-admin      | 2022-09-24 10:00:29 [http-nio-0.0.0.0-9095-exec-1] INFO  org.springframework.web.servlet.DispatcherServlet - Initializing Servlet 'dispatcherServlet'
shenyu-admin      | 2022-09-24 10:00:29 [http-nio-0.0.0.0-9095-exec-1] INFO  org.springframework.web.servlet.DispatcherServlet - Completed initialization in 2 ms
shenyu-admin      | 2022-09-24 10:00:29 [http-nio-0.0.0.0-9095-exec-1] INFO  org.apache.shenyu.admin.listener.websocket.WebsocketCollector - websocket on client[172.18.0.2] open successful,maxTextMessageBufferSize:10240
shenyu-bootstrap  | 2022-09-24 10:00:29 [shenyu-shared_wheel_timer-4] INFO  org.apache.shenyu.plugin.sync.data.websocket.client.ShenyuWebsocketClient - websocket connection server[ws://shenyu-admin:9095/websocket] is successful.....
shenyu-bootstrap  | 2022-09-24 10:00:29 [WebSocketConnectReadThread-34] INFO  org.apache.shenyu.plugin.sync.data.websocket.client.ShenyuWebsocketClient - handleResult({"groupType":"PLUGIN","eventType":"MYSELF","data":[{"id":"1","name":"sign","role":"Authentication","enabled":false,"sort":20},{"id":"2","name":"waf","config":"{\"model\":\"black\"}","role":"Authentication","enabled":false,"sort":50},{"id":"3","name":"rewrite","role":"HttpProcess","enabled":false,"sort":90},{"id":"4","name":"rateLimiter","config":"{\"master\":\"mymaster\",\"mode\":\"standalone\",\"url\":\"192.168.1.1:6379\",\"password\":\"abc\"}","role":"FaultTolerance","enabled":false,"sort":60},{"id":"5","name":"divide","config":"{\"multiSelectorHandle\":\"1\",\"multiRuleHandle\":\"0\"}","role":"Proxy","enabled":true,"sort":200},{"id":"6","name":"dubbo","config":"{\"register\":\"zookeeper://localhost:2181\",\"multiSelectorHandle\":\"1\",\"threadpool\":\"shared\",\"corethreads\":0,\"threads\":2147483647,\"queues\":0}","role":"Proxy","enabled":false,"sort":310},{"id":"8","name":"springCloud","role":"Proxy","enabled":false,"sort":200},{"id":"9","name":"hystrix","role":"FaultTolerance","enabled":false,"sort":130},{"id":"10","name":"sentinel","role":"FaultTolerance","enabled":false,"sort":140},{"id":"11","name":"sofa","config":"{\"protocol\":\"zookeeper\",\"register\":\"127.0.0.1:2181\",\"threadpool\":\"shared\"}","role":"Proxy","enabled":false,"sort":310},{"id":"12","name":"resilience4j","role":"FaultTolerance","enabled":false,"sort":310},{"id":"13","name":"tars","config":"{\"multiSelectorHandle\":\"1\",\"multiRuleHandle\":\"0\",\"threadpool\":\"shared\"}","role":"Proxy","enabled":false,"sort":310},{"id":"14","name":"contextPath","role":"HttpProcess","enabled":true,"sort":80},{"id":"15","name":"grpc","config":"{\"multiSelectorHandle\":\"1\",\"multiRuleHandle\":\"0\",\"threadpool\":\"shared\"}","role":"Proxy","enabled":false,"sort":310},{"id":"16","name":"redirect","role":"HttpProcess","enabled":false,"sort":110},{"id":"17","name":"motan","config":"{\"register\":\"127.0.0.1:2181\",\"corethreads\":0,\"threads\":2147483647,\"queues\":0,\"threadpool\":\"shared\"}","role":"Proxy","enabled":false,"sort":310},{"id":"18","name":"loggingConsole","role":"Logging","enabled":false,"sort":160},{"id":"19","name":"jwt","config":"{\"secretKey\":\"key\"}","role":"Authentication","enabled":false,"sort":30},{"id":"20","name":"request","role":"HttpProcess","enabled":false,"sort":120},{"id":"21","name":"oauth2","role":"Authentication","enabled":false,"sort":40},{"id":"22","name":"paramMapping","config":"{\"ruleHandlePageType\":\"custom\"}","role":"HttpProcess","enabled":false,"sort":70},{"id":"23","name":"modifyResponse","config":"{\"ruleHandlePageType\":\"custom\"}","role":"HttpProcess","enabled":false,"sort":220},{"id":"24","name":"cryptorRequest","role":"Cryptor","enabled":true,"sort":100},{"id":"25","name":"cryptorResponse","role":"Cryptor","enabled":true,"sort":410},{"id":"26","name":"websocket","config":"{\"multiSelectorHandle\":\"1\"}","role":"Proxy","enabled":true,"sort":200},{"id":"27","name":"generalContext","role":"Common","enabled":true,"sort":125},{"id":"28","name":"mqtt","config":"{\"port\": 9500,\"bossGroupThreadCount\": 1,\"maxPayloadSize\": 65536,\"workerGroupThreadCount\": 12,\"userName\": \"shenyu\",\"password\": \"shenyu\",\"isEncryptPassword\": false,\"encryptMode\": \"\",\"leakDetectorLevel\": \"DISABLED\"}","role":"Proxy","enabled":false,"sort":125},{"id":"29","name":"loggingRocketMQ","config":"{\"topic\":\"shenyu-access-logging\", \"namesrvAddr\": \"localhost:9876\",\"producerGroup\":\"shenyu-plugin-logging-rocketmq\"}","role":"Logging","enabled":false,"sort":170},{"id":"30","name":"cache","config":"{\"cacheType\":\"memory\"}","role":"Cache","enabled":false,"sort":10},{"id":"31","name":"mock","role":"Mock","enabled":false,"sort":1},{"id":"32","name":"loggingElasticSearch","config":"{\"host\":\"localhost\", \"port\": \"9200\"}","role":"Logging","enabled":false,"sort":190},{"id":"33","name":"loggingKafka","config":"{\"topic\":\"shenyu-access-logging\", \"namesrvAddr\": \"localhost:9092\"}","role":"Logging","enabled":false,"sort":180},{"id":"34","name":"loggingAliyunSls","config":"{\"projectName\": \"shenyu\", 
\"logStoreName\": \"shenyu-logstore\", \"topic\": \"shenyu-topic\"}","role":"Logging","enabled":false,"sort":175},{"id":"35","name":"loggingPulsar","config":"{\"topic\":\"shenyu-access-logging\", \"serviceUrl\": \"pulsar://localhost:6650\"}","role":"Logging","enabled":false,"sort":185},{"id":"36","name":"loggingTencentCls","config":"{\"endpoint\": \"ap-guangzhou.cls.tencentcs.com\", \"topic\": \"shenyu-topic\"}","role":"Logging","enabled":false,"sort":176},{"id":"38","name":"loggingClickHouse","config":"{\"host\":\"127.0.0.1\",\"port\":\"8123\",\"databse\":\"shenyu-gateway\",\"username\":\"foo\",\"password\":\"bar\"}","role":"Logging","enabled":false,"sort":195}]})       
shenyu-bootstrap  | 2022-09-24 10:00:29 [WebSocketConnectReadThread-34] INFO  org.apache.shenyu.web.handler.ShenyuWebHandler - shenyu use plugin:[divide]
shenyu-bootstrap  | 2022-09-24 10:00:29 [WebSocketConnectReadThread-34] INFO  org.apache.shenyu.web.handler.ShenyuWebHandler - shenyu use plugin:[contextPath]
shenyu-bootstrap  | 2022-09-24 10:00:29 [WebSocketConnectReadThread-34] INFO  org.apache.shenyu.web.handler.ShenyuWebHandler - shenyu use plugin:[cryptorRequest]
shenyu-bootstrap  | 2022-09-24 10:00:29 [WebSocketConnectReadThread-34] INFO  org.apache.shenyu.web.handler.ShenyuWebHandler - shenyu use plugin:[cryptorResponse]        
shenyu-bootstrap  | 2022-09-24 10:00:29 [WebSocketConnectReadThread-34] INFO  org.apache.shenyu.web.handler.ShenyuWebHandler - shenyu use plugin:[websocket]
shenyu-bootstrap  | 2022-09-24 10:00:29 [WebSocketConnectReadThread-34] INFO  org.apache.shenyu.web.handler.ShenyuWebHandler - shenyu use plugin:[generalContext]
shenyu-bootstrap  | 2022-09-24 10:00:29 [WebSocketConnectReadThread-34] INFO  org.apache.shenyu.plugin.logging.common.handler.AbstractLogPluginDataHandler - handler loggingRocketMQ Plugin data: {"id":"29","name":"loggingRocketMQ","config":"{\"topic\":\"shenyu-access-logging\", \"namesrvAddr\": \"localhost:9876\",\"producerGroup\":\"shenyu-plugin-logging-rocketmq\"}","role":"Logging","enabled":false,"sort":170}
shenyu-bootstrap  | 2022-09-24 10:00:29 [WebSocketConnectReadThread-34] INFO  org.apache.shenyu.plugin.cache.handler.CachePluginDataHandler - the plugin cache is disabledshenyu-bootstrap  | 2022-09-24 10:00:29 [WebSocketConnectReadThread-34] INFO  org.apache.shenyu.plugin.logging.common.handler.AbstractLogPluginDataHandler - handler loggingElasticSearch Plugin data: {"id":"32","name":"loggingElasticSearch","config":"{\"host\":\"localhost\", \"port\": \"9200\"}","role":"Logging","enabled":false,"sort":190}shenyu-bootstrap  | 2022-09-24 10:00:29 [WebSocketConnectReadThread-34] INFO  org.apache.shenyu.plugin.logging.common.handler.AbstractLogPluginDataHandler - handler loggingKafka Plugin data: {"id":"33","name":"loggingKafka","config":"{\"topic\":\"shenyu-access-logging\", \"namesrvAddr\": \"localhost:9092\"}","role":"Logging","enabled":false,"sort":180}
shenyu-bootstrap  | 2022-09-24 10:00:29 [WebSocketConnectReadThread-34] INFO  org.apache.shenyu.plugin.logging.common.handler.AbstractLogPluginDataHandler - handler loggingAliyunSls Plugin data: {"id":"34","name":"loggingAliyunSls","config":"{\"projectName\": \"shenyu\", \"logStoreName\": \"shenyu-logstore\", \"topic\": \"shenyu-topic\"}","role":"Logging","enabled":false,"sort":175}
shenyu-bootstrap  | 2022-09-24 10:00:29 [WebSocketConnectReadThread-34] INFO  org.apache.shenyu.plugin.logging.common.handler.AbstractLogPluginDataHandler - handler loggingPulsar Plugin data: {"id":"35","name":"loggingPulsar","config":"{\"topic\":\"shenyu-access-logging\", \"serviceUrl\": \"pulsar://localhost:6650\"}","role":"Logging","enabled":false,"sort":185}
shenyu-bootstrap  | 2022-09-24 10:00:29 [WebSocketConnectReadThread-34] INFO  org.apache.shenyu.plugin.logging.common.handler.AbstractLogPluginDataHandler - handler loggingTencentCls Plugin data: {"id":"36","name":"loggingTencentCls","config":"{\"endpoint\": \"ap-guangzhou.cls.tencentcs.com\", \"topic\": \"shenyu-topic\"}","role":"Logging","enabled":false,"sort":176}
shenyu-bootstrap  | 2022-09-24 10:00:29 [WebSocketConnectReadThread-34] INFO  org.apache.shenyu.plugin.logging.common.handler.AbstractLogPluginDataHandler - handler loggingClickHouse Plugin data: {"id":"38","name":"loggingClickHouse","config":"{\"host\":\"127.0.0.1\",\"port\":\"8123\",\"databse\":\"shenyu-gateway\",\"username\":\"foo\",\"password\":\"bar\"}","role":"Logging","enabled":false,"sort":195}
shenyu-bootstrap  | 2022-09-24 10:00:29 [WebSocketConnectReadThread-34] INFO  org.apache.shenyu.plugin.sync.data.websocket.client.ShenyuWebsocketClient - handleResult({"groupType":"SELECTOR","eventType":"MYSELF","data":[]})
shenyu-bootstrap  | 2022-09-24 10:00:29 [WebSocketConnectReadThread-34] INFO  org.apache.shenyu.plugin.sync.data.websocket.client.ShenyuWebsocketClient - handleResult({"groupType":"RULE","eventType":"MYSELF","data":[]})
JooKS-me commented 1 year ago

@aFlyBird0 Could you help with this issue?

skyleaworlder commented 1 year ago

I add a few more log about this issue:

When shenyu-bootstrap fails to build a ws connection, shenyu-admin reports:

2022-09-24 10:44:45 [main] INFO  springfox.documentation.spring.web.readers.operation.CachingOperationNameGenerator - Generating unique operation named: detailUsingGET_3 
2022-09-24 10:44:45 [main] INFO  org.apache.shenyu.admin.ShenyuAdminBootstrap - Started ShenyuAdminBootstrap in 9.2 seconds (JVM running for 9.728)
2022-09-24 10:44:45 [main] WARN  org.apache.shenyu.admin.utils.SessionUtil - get user info error ,not found, used default user ,it unknown
2022-09-24 10:44:46 [http-nio-0.0.0.0-9095-exec-1] INFO  org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/] - Initializing Spring DispatcherServlet 'dispatcherServlet'
2022-09-24 10:44:46 [http-nio-0.0.0.0-9095-exec-1] INFO  org.springframework.web.servlet.DispatcherServlet - Initializing Servlet 'dispatcherServlet'
2022-09-24 10:44:46 [http-nio-0.0.0.0-9095-exec-1] INFO  org.springframework.web.servlet.DispatcherServlet - Completed initialization in 2 ms
2022-09-24 10:44:46 [http-nio-0.0.0.0-9095-exec-1] ERROR org.apache.shenyu.admin.listener.websocket.WebsocketConfigurator - originHeaderValue is forbidden: ws://shenyu-bootstrap.shenyu.svc.cluster.local:9195
2022-09-24 10:44:56 [http-nio-0.0.0.0-9095-exec-2] ERROR org.apache.shenyu.admin.listener.websocket.WebsocketConfigurator - originHeaderValue is forbidden: ws://shenyu-bootstrap.shenyu.svc.cluster.local:9195

And I locate this piece of log:

// org.apache.shenyu.admin.listener.websocket.WebsocketConfigurator
@Override
public boolean checkOrigin(final String originHeaderValue) {
    final WebsocketSyncProperties bean = SpringBeanUtils.getInstance().getBean(WebsocketSyncProperties.class);
    if (StringUtils.isNotEmpty(bean.getAllowOrigins())) {
        String[] split = StringUtils.split(bean.getAllowOrigins(), ";");
        for (String configAllow : split) {
            if (StringUtils.equals(configAllow, originHeaderValue)) {
                return true;
            }
        }
        LOG.error("originHeaderValue is forbidden: " + originHeaderValue);
        return false;
    }
    return super.checkOrigin(originHeaderValue);
}

It seems that the "AllowOrigin" value passed in doesn't equal ws request header.

JooKS-me commented 1 year ago

I think you can see this to configure shenyu.sync.websocket.allowOrigins @skyleaworlder

https://shenyu.apache.org/zh/docs/user-guide/property-config/admin-property-config#shenyusync-%E9%85%8D%E7%BD%AE

skyleaworlder commented 1 year ago

I think you can see this to configure shenyu.sync.websocket.allowOrigins @skyleaworlder

https://shenyu.apache.org/zh/docs/user-guide/property-config/admin-property-config#shenyusync-%E9%85%8D%E7%BD%AE

Thanks. Actually I forgot to read manuals about application config. But this manual doesn't solve this.

# shenyu-admin
2022-09-24 11:33:58 [http-nio-0.0.0.0-9095-exec-5] ERROR org.apache.shenyu.admin.listener.websocket.WebsocketConfigurator - originHeaderValue is forbidden: ws://shenyu-bootstrap.shenyu.svc.cluster.local:9195
2022-09-24 11:34:08 [http-nio-0.0.0.0-9095-exec-7] ERROR org.apache.shenyu.admin.listener.websocket.WebsocketConfigurator - originHeaderValue is forbidden: ws://shenyu-bootstrap.shenyu.svc.cluster.local:9195

# shenyu-bootstrap
2022-09-24 11:33:58 [shenyu-shared_wheel_timer-4] WARN  org.apache.shenyu.plugin.sync.data.websocket.client.ShenyuWebsocketClient - websocket connection server[ws://shenyu-admin.shenyu.svc.cluster.local:9095/websocket] is error.....
2022-09-24 11:34:08 [shenyu-shared_wheel_timer-4] WARN  org.apache.shenyu.plugin.sync.data.websocket.client.ShenyuWebsocketClient - websocket connection server[ws://shenyu-admin.shenyu.svc.cluster.local:9095/websocket] is error.....

Here shenyu-helm-chart provides a basic configuration:

      sync:
        websocket:
          urls: ws://{{ template "common.names.fullname" . }}-admin.shenyu.svc.cluster.local:9095/websocket
          allowOrigin: ws://{{ template "common.names.fullname" . }}-bootstrap.shenyu.svc.cluster.local:9195

And I also check it in shenyu-bootstrap pod:

allowOrigin: ws://shenyu-bootstrap.shenyu.svc.cluster.local:9195
urls: ws://shenyu-admin.shenyu.svc.cluster.local:9095/websocket
```yaml /opt/shenyu-bootstrap/conf # cat application.yml eureka: client: enabled: false serviceUrl: defaultZone: http://localhost:8761/eureka/ instance: prefer-ip-address: true logging: level: org.apache.ibatis: info org.apache.shenyu: info org.apache.shenyu.bonuspoint: info org.apache.shenyu.lottery: info org.springframework.boot: info root: info management: health: defaults: enabled: false server: address: 0.0.0.0 port: 9195 shenyu: cross: allowCredentials: true allowedAnyOrigin: true allowedExpose: "" allowedHeaders: null allowedMethods: '*' enabled: true maxAge: "18000" exclude: enabled: false paths: - /favicon.ico extPlugin: enabled: true path: null scheduleDelay: 30 scheduleTime: 300 threads: 1 fallback: enabled: false paths: - /fallback/hystrix - /fallback/resilience4j file: enabled: true maxSize: 10 health: enabled: false paths: - /actuator/health - /health_check instance: enabled: false props: null registerType: zookeeper serverLists: localhost:2181 local: enabled: false sha512Key: BA3253876AED6BC22D4A6FF53D8406C6AD864195ED144AB5C87621B6C233B548BAEAE6956DF346EC8C17F5EA10F35EE3CBC514797ED7DDD3145464E2A0BAB413 matchCache: enabled: false maxFreeMemory: 256 metrics: enabled: false host: 127.0.0.1 jmxConfig: null name: prometheus port: 8090 props: jvm_enabled: true netty: http: accessLog: false selectCount: 1 serverSocketChannel: allocType: pooled autoRead: false connectTimeoutMillis: 10000 messageSizeEstimator: 8 singleEventExecutorPerGroup: true soBackLog: 128 soRcvBuf: 87380 soReuseAddr: false writeBufferHighWaterMark: 65536 writeBufferLowWaterMark: 32768 writeSpinCount: 16 socketChannel: allocType: pooled allowHalfClosure: false autoRead: false connectTimeoutMillis: 10000 ipTos: 0 messageSizeEstimator: 8 singleEventExecutorPerGroup: true soKeepAlive: false soLinger: -1 soRcvBuf: 87380 soReuseAddr: false soSndBuf: 16384 tcpNoDelay: true writeBufferHighWaterMark: 65536 writeBufferLowWaterMark: 32768 writeSpinCount: 16 webServerFactoryEnabled: true workerCount: 4 ribbon: serverListRefreshInterval: 10000 scheduler: enabled: false threads: 16 type: fixed switchConfig: local: true sync: websocket: allowOrigin: ws://shenyu-bootstrap.shenyu.svc.cluster.local:9195 urls: ws://shenyu-admin.shenyu.svc.cluster.local:9095/websocket upstreamCheck: enabled: false healthyThreshold: 1 interval: 5000 printEnabled: true printInterval: 60000 timeout: 3000 unhealthyThreshold: 1 spring: application: name: shenyu-bootstrap cloud: discovery: enabled: false nacos: discovery: enabled: false namespace: ShenyuRegisterCenter server-addr: 127.0.0.1:8848 codec: max-in-memory-size: 2MB main: allow-bean-definition-overriding: true ```
skyleaworlder commented 1 year ago

I think you can see this to configure shenyu.sync.websocket.allowOrigins @skyleaworlder https://shenyu.apache.org/zh/docs/user-guide/property-config/admin-property-config#shenyusync-%E9%85%8D%E7%BD%AE

Thanks. Actually I forgot to read manuals about application config. But this manual doesn't solve this.

# shenyu-admin
2022-09-24 11:33:58 [http-nio-0.0.0.0-9095-exec-5] ERROR org.apache.shenyu.admin.listener.websocket.WebsocketConfigurator - originHeaderValue is forbidden: ws://shenyu-bootstrap.shenyu.svc.cluster.local:9195
2022-09-24 11:34:08 [http-nio-0.0.0.0-9095-exec-7] ERROR org.apache.shenyu.admin.listener.websocket.WebsocketConfigurator - originHeaderValue is forbidden: ws://shenyu-bootstrap.shenyu.svc.cluster.local:9195

# shenyu-bootstrap
2022-09-24 11:33:58 [shenyu-shared_wheel_timer-4] WARN  org.apache.shenyu.plugin.sync.data.websocket.client.ShenyuWebsocketClient - websocket connection server[ws://shenyu-admin.shenyu.svc.cluster.local:9095/websocket] is error.....
2022-09-24 11:34:08 [shenyu-shared_wheel_timer-4] WARN  org.apache.shenyu.plugin.sync.data.websocket.client.ShenyuWebsocketClient - websocket connection server[ws://shenyu-admin.shenyu.svc.cluster.local:9095/websocket] is error.....

Here shenyu-helm-chart provides a basic configuration:

      sync:
        websocket:
          urls: ws://{{ template "common.names.fullname" . }}-admin.shenyu.svc.cluster.local:9095/websocket
          allowOrigin: ws://{{ template "common.names.fullname" . }}-bootstrap.shenyu.svc.cluster.local:9195

And I also check it in shenyu-bootstrap pod:

allowOrigin: ws://shenyu-bootstrap.shenyu.svc.cluster.local:9195
urls: ws://shenyu-admin.shenyu.svc.cluster.local:9095/websocket

I see. I got the reason now.

And I also find #15 has already fixed it. Thanks.

aFlyBird0 commented 1 year ago

Thank you from the heart of my bottom! Thank you for testing this chart and paste so detailed debug logs!!! ❤️

It's all my fault, caused by a typo. I have submitted a PR to fix it: #15

By the way, this chart follows the semanticized version, currently the big version number is "0", that is, not officially released, still in continuous testing. Thank you very much for your testing, a lot of testing will be needed later when we change the version number from "0" to "1", thanks!

aFlyBird0 commented 1 year ago

There are two ways to handle this problem:

1. uninstall helm and reinstall

  1. use helm uninstall ... to uninstall old release
  2. kubectl delete ns shenyu
  3. edit values.yaml according to #15
  4. helm install ......

2. edit configmaps and restart pods

  1. kubectl edit configmaps shenyu-configmap -n shenyu
  2. edit configmaps according to #15
  3. execute kubectl get pods -n shenyu to get pods name of shenyu-admin and shenyu-bootstrap
  4. execute kubectl delete pod/shenyu-admin....... -n shenyu and kubectl delete pod/shenyu-boostrap.... -n shenyu to delete pods
  5. wait K8s to scale Pods automatically

@skyleaworlder 🚀