sermant-io / Sermant

A Cloud-Native Proxyless Service Mesh based on Java Bytecode Enhancement Technology
https://sermant.io/
Apache License 2.0
1.21k stars 161 forks source link

路由标签不生效 #1220

Closed DogerRain closed 1 year ago

DogerRain commented 1 year ago

What do you want to ask?

我按照官方文档:https://sermant.io/zh/document/plugin/router.html 下载了demo进行测试,尝试了多次,路由也不生效,特此前来求助。

系统:windows

sermant版本:[1.0.3](https://github.com/huaweicloud/Sermant/releases/tag/v1.0.3)

servicecomb版本:apache-servicecomb-service-center-2.1.0-windows-amd64

zk版本:3.6.3


以下是我本地的配置:

1、服务配置

ZuulApplication、ProviderApplication、ConsumerApplication:

-Dservicecomb_service_enableSpringRegister=true -javaagent:G:\project\gray\sermant-agent\agent\sermant-agent.jar=appName=default

ProviderApplication-1.0.1:

-Dservicecomb_service_enableSpringRegister=true -Dservice_meta_version=1.0.1 -Dservice_meta_parameters=group:gray -Dserver.port=8163 -javaagent:G:\project\gray\sermant-agent\agent\sermant-agent.jar=appName=default

2、servicecomb

四个服务都成功注册到servicecomb

3、agent配置

\agent\config\config.properties 文件配置

# agent config
agent.config.isEnhanceBootStrapEnable=true
agent.config.ignoredPrefixes=com.huawei.sermant,com.huaweicloud.sermant
agent.config.ignoredInterfaces=org.springframework.cglib.proxy.Factory
agent.config.combineStrategy=ALL
agent.config.serviceBlackList=com.huaweicloud.sermant.implement.service.heartbeat.HeartbeatServiceImpl,com.huaweicloud.sermant.implement.service.send.NettyGatewayClient,com.huaweicloud.sermant.implement.service.tracing.TracingServiceImpl
agent.config.serviceInjectList=com.huawei.discovery.service.lb.filter.NopInstanceFilter,com.huawei.discovery.service.lb.DiscoveryManager

# adaptor config
adaptor.config.isLoadExtAgentEnable=false

# dynamic config
dynamic.config.timeoutValue=30000
dynamic.config.defaultGroup=sermant
dynamic.config.serverAddress=127.0.0.1:2181
dynamic.config.dynamicConfigType=ZOOKEEPER
dynamic.config.connectRetryTimes=5
dynamic.config.connectTimeout=1000
dynamic.config.userName=
dynamic.config.password=
dynamic.config.privateKey=
dynamic.config.enableAuth=false

# heartbeat config
heartbeat.interval=30000

#backend config
backend.nettyIp=127.0.0.1
backend.nettyPort=6888
backend.httpIp=127.0.0.1
backend.httpPort=8900

# service meta config
service.meta.application=default
service.meta.version=1.0.0
service.meta.project=default
service.meta.environment=
service.meta.zone=

4、zk配置

【本地】127.0.0.1:2181  $   get /app=default&environment=/servicecomb.routeRule.spring-cloud-router-provider
---
- precedence: 1
  match:
    headers:
      id:
        exact: '1'
        caseInsensitive: false
  route:
    - tags:
        group: gray
      weight: 100
- precedence: 2
  match:
    headers:
      id:
        exact: '2'
        caseInsensitive: false
  route:
    - tags:
        version: 1.0.1
      weight: 100

调用结果却没生效...

> curl -H "id: 1" http://127.0.0.1:8170/consumer/hello/rest
Hello world! My port is 8162, my version is 1.0.0.
Administrator@HAC C:\Users\Administrator
> curl -H "id: 1" http://127.0.0.1:8170/consumer/hello/rest
Hello world! My port is 8163, my version is 1.0.1.
Administrator@HAC C:\Users\Administrator
> curl -H "id: 10" http://127.0.0.1:8170/consumer/hello/rest
Hello world! My port is 8162, my version is 1.0.0.
Administrator@HAC C:\Users\Administrator
> curl -H "id: 10" http://127.0.0.1:8170/consumer/hello/rest
Hello world! My port is 8163, my version is 1.0.1.

是不是我本地哪里配置错误了,求大佬解答,不胜感激。

provenceee commented 1 year ago

我本地测试是可以的。尝试从以下方面排查下:

1.查看sermant日志,确认配置是否下发成功,sermant日志在启动目录下的logs\sermant\core\app\yyyy-MM-dd文件夹中。可搜索关键字:Config [servicecomb.routeRule.spring-cloud-router-provider] has been

2.确认sermant版本必须是sermant 1.0.x,不要从dev分支中打包获取,dev分支中为1.1.x。

3.尝试换一个http客户端,windows的curl,在某些情况下,有可能无法正确地发送请求头

luanwenfei-venus commented 1 year ago

长时间不活跃,关闭ISSUE