You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/06/29 14:14:06 UTC
[GitHub] [servicecomb-java-chassis] cmkcmk181 opened a new issue #1859: 无法正确使用nacos,在nacos中配置路由不生效
cmkcmk181 opened a new issue #1859:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1859
java-chassis版本:2.0.2
nacos-server版本:1.1.4
问题:
nacos配置如下:

在启动应用的过程中无法解析yaml格式,报错如下:

如果将配置中心的格式改为json后不会报错,但路由并未生效。
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #1859: 无法正确使用nacos,在nacos中配置路由不生效
Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #1859:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1859#issuecomment-651564052
那应该是早期模块的贡献者没有考虑支持 `yaml` 格式了。 你有没有兴趣结合你的场景修改代码,提交个 PR?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] cmkcmk181 commented on issue #1859: 无法正确使用nacos,在nacos中配置路由不生效
Posted by GitBox <gi...@apache.org>.
cmkcmk181 commented on issue #1859:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1859#issuecomment-656689353
好的,是JSON转map的问题,框架内有现成的转换方法吗?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] cmkcmk181 commented on issue #1859: 无法正确使用nacos,在nacos中配置路由不生效
Posted by GitBox <gi...@apache.org>.
cmkcmk181 commented on issue #1859:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1859#issuecomment-656522045
nacos的配置如下:

----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #1859: 无法正确使用nacos,在nacos中配置路由不生效
Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #1859:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1859#issuecomment-653377499
应该不是这个原因。 你调试的时候 'added' 包含下发的配置吗? 这个代码是为了兼容做的特殊处理, 即将 'cse.xxx' 拷贝一份 'servicecomb.xxx'。
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] cmkcmk181 commented on issue #1859: 无法正确使用nacos,在nacos中配置路由不生效
Posted by GitBox <gi...@apache.org>.
cmkcmk181 commented on issue #1859:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1859#issuecomment-657919781
已提交PR
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #1859: 无法正确使用nacos,在nacos中配置路由不生效
Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #1859:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1859#issuecomment-667003574
@cmkcmk181 This PR have some improvements need fix. Do you have time to finish it? Or need others help?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #1859: 无法正确使用nacos,在nacos中配置路由不生效
Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #1859:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1859#issuecomment-672546618
fixed in 2.1.1
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] liubao68 edited a comment on issue #1859: 无法正确使用nacos,在nacos中配置路由不生效
Posted by GitBox <gi...@apache.org>.
liubao68 edited a comment on issue #1859:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1859#issuecomment-672547450
文档配置进行了刷新,参考: https://docs.servicecomb.io/java-chassis/zh_CN/config/general-config/
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #1859: 无法正确使用nacos,在nacos中配置路由不生效
Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #1859:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1859#issuecomment-656525482
你可以试试在 URLMappedEdgeDispatcher 下面的代码打个断点看看,更新配置的时候, 这个 listener 是否被执行到。
```
private void loadConfigurations() {
ConcurrentCompositeConfiguration config = (ConcurrentCompositeConfiguration) DynamicPropertyFactory
.getBackingConfigurationSource();
configurations = URLMappedConfigurationLoader.loadConfigurations(config, KEY_MAPPING_PREFIX);
config.addConfigurationListener(event -> {
if (event.getPropertyName().startsWith(KEY_MAPPING_PREFIX)) {
LOG.info("Map rule have been changed. Reload configurations. Event=" + event.getType());
configurations = URLMappedConfigurationLoader.loadConfigurations(config, KEY_MAPPING_PREFIX);
}
});
}
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #1859: 无法正确使用nacos,在nacos中配置路由不生效
Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #1859:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1859#issuecomment-656543596
我突然想到可能什么原因了, 配置项被转换为 Map of Map , 而不是 Map of key String and value String. 这个地方也是 bug .. 这部分贡献的代码测试不充分... 。 你如果继续使用,可以考虑将这个类本地拷贝一份, 和业务代码一起编译,把发现的bug改下。 如果你方便的话,可以将修改代码提交一个 PR。 项目维护人数比较少, 最近我也抽不出时间来帮忙修复。 短期内看你需要大家帮忙修复了, 或者等我把手头事情弄完后修复。
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] liubao68 closed issue #1859: 无法正确使用nacos,在nacos中配置路由不生效
Posted by GitBox <gi...@apache.org>.
liubao68 closed issue #1859:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1859
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #1859: 无法正确使用nacos,在nacos中配置路由不生效
Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #1859:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1859#issuecomment-651796538
我看了下代码, 你又帮忙发现一个 bug, 有两个地方读取的配置项值不一样。 应该是最开始用的 nacos.config.servierAddr, 后面提了个检视意见,改成了 servicecomb.nacos.serverAddr, 有个地方忘记改了。
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] cmkcmk181 commented on issue #1859: 无法正确使用nacos,在nacos中配置路由不生效
Posted by GitBox <gi...@apache.org>.
cmkcmk181 commented on issue #1859:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1859#issuecomment-651529175
应该不缩进的问题改了也是报错,在NacosClient.java中解析yaml格式的字符串时报错了,如下:

----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] cmkcmk181 edited a comment on issue #1859: 无法正确使用nacos,在nacos中配置路由不生效
Posted by GitBox <gi...@apache.org>.
cmkcmk181 edited a comment on issue #1859:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1859#issuecomment-656510363
content和body都有值,格式都没有问题,但是路由还是不生效。直接配置在microservice.yaml中是生效的

json格式如下:
{
"servicecomb": {
"edge": {
"filter": {
"addHeader": {
"enabled": true,
"allowedHeaders": "Authorization"
}
}
},
"http": {
"dispatcher": {
"edge": {
"url": {
"enabled": true,
"pattern": "/(.*)",
"mappings": {
"authV1": {
"prefixSegmentCount": 1,
"path": "/api/auth/v1/.*",
"microserviceName": "fw-auth",
"versionRule": "1.0.0-2.0.0"
}
}
}
}
}
}
}
}
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] cmkcmk181 commented on issue #1859: 无法正确使用nacos,在nacos中配置路由不生效
Posted by GitBox <gi...@apache.org>.
cmkcmk181 commented on issue #1859:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1859#issuecomment-656510363
content和body都有值,但是路由还是不生效。直接配置在microservice.yaml中是生效的

json格式如下:
{
"servicecomb": {
"edge": {
"filter": {
"addHeader": {
"enabled": true,
"allowedHeaders": "Authorization"
}
}
},
"http": {
"dispatcher": {
"edge": {
"url": {
"enabled": true,
"pattern": "/(.*)",
"mappings": {
"authV1": {
"prefixSegmentCount": 1,
"path": "/api/auth/v1/.*",
"microserviceName": "fw-auth",
"versionRule": "1.0.0-2.0.0"
}
}
}
}
}
}
}
}
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] cmkcmk181 commented on issue #1859: 无法正确使用nacos,在nacos中配置路由不生效
Posted by GitBox <gi...@apache.org>.
cmkcmk181 commented on issue #1859:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1859#issuecomment-651624249
在microservice.yaml中的配置也比较奇怪,要在两个地方写配置中心的地址,少写一个就会报错:

----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] cmkcmk181 commented on issue #1859: 无法正确使用nacos,在nacos中配置路由不生效
Posted by GitBox <gi...@apache.org>.
cmkcmk181 commented on issue #1859:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1859#issuecomment-652876560
我改为json的格式配置也不生效,我跟踪了代码发现以下if条件不满足,是不是和这个有关系?

怎么会有cse.开头的?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #1859: 无法正确使用nacos,在nacos中配置路由不生效
Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #1859:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1859#issuecomment-672547450
文档配置进行类刷新,参考: https://docs.servicecomb.io/java-chassis/zh_CN/config/general-config/
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] liubao68 edited a comment on issue #1859: 无法正确使用nacos,在nacos中配置路由不生效
Posted by GitBox <gi...@apache.org>.
liubao68 edited a comment on issue #1859:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1859#issuecomment-653377499
应该不是这个原因。 你调试的时候 'added' 包含下发的配置吗? 这个代码是为了兼容做的特殊处理, 即将 'cse.xxx' 拷贝一份 'servicecomb.xxx'。 关键是下面的一段代码返回的指是否符合预期:`content ` 和 `body`
```
void refreshConfig() {
Properties properties = new Properties();
properties.put("serverAddr", serverAddr);
properties.put("dataId", dataId);
properties.put("group", group);
try {
ConfigService configService = NacosFactory.createConfigService(properties);
String content = configService.getConfig(dataId, group, 5000);
Map<String, Object> body = JsonUtils.OBJ_MAPPER.readValue(content,
new TypeReference<Map<String, Object>>() {
});
refreshConfigItems(body);
configService.addListener(dataId, group, new Listener() {
@Override
public void receiveConfigInfo(String configInfo) {
LOGGER.info("receive from nacos:" + configInfo);
try {
Map<String, Object> body = JsonUtils.OBJ_MAPPER.readValue(configInfo,
new TypeReference<Map<String, Object>>() {
});
refreshConfigItems(body);
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] cmkcmk181 commented on issue #1859: 无法正确使用nacos,在nacos中配置路由不生效
Posted by GitBox <gi...@apache.org>.
cmkcmk181 commented on issue #1859:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1859#issuecomment-656521200
不是,只有一个servicecomb.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] cmkcmk181 commented on issue #1859: 无法正确使用nacos,在nacos中配置路由不生效
Posted by GitBox <gi...@apache.org>.
cmkcmk181 commented on issue #1859:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1859#issuecomment-651621271
json比较麻烦
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #1859: 无法正确使用nacos,在nacos中配置路由不生效
Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #1859:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1859#issuecomment-656520029
我看你的截图,貌似json配置的配置项是 `servicecomb.servicecomb.*`
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #1859: 无法正确使用nacos,在nacos中配置路由不生效
Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #1859:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1859#issuecomment-651513582
路由不生效的问题,可以通过调试 `CommonHttpEdgeDispatcher` 分析下。 报错看起来应该是你的配置错误了, 多了一个 TAB 缩进。
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] liubao68 edited a comment on issue #1859: 无法正确使用nacos,在nacos中配置路由不生效
Posted by GitBox <gi...@apache.org>.
liubao68 edited a comment on issue #1859:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1859#issuecomment-656543596
我突然想到可能什么原因了, 配置项被转换为 Map of Map , 而不是 Map of key String and value String. 这个地方也是 bug .. 这部分贡献的代码测试不充分... 。 你如果继续使用,可以考虑将这个类本地拷贝一份, 和业务代码一起编译,把发现的bug改下。 如果你方便的话,可以将修改代码提交一个 PR。 项目维护人数比较少, 最近我也抽不出时间来帮忙修复。 短期内看需要大家帮忙修复了, 或者等我把手头事情弄完后修复。
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #1859: 无法正确使用nacos,在nacos中配置路由不生效
Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #1859:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1859#issuecomment-651591575
检查了下代码的 readme, 早期代码确实只实现了 `json` 的支持, 参考: https://github.com/apache/servicecomb-java-chassis/tree/master/dynamic-config/config-nacos
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org