alibaba / nacos

an easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.
https://nacos.io
Apache License 2.0
30.21k stars 12.83k forks source link

与SpringCloud Gateway 整合时报404 #5631

Closed Taogang00 closed 3 years ago

Taogang00 commented 3 years ago

Describe the bug A clear and concise description of what the bug is.

你好,我在使用SCA+nacos2021.1+ SpringCloud 2020.0.2+ SpringBoot2.4.5 创建了2个服务, spring cloud gateway 和一个account-service 。nacos作服务发现组件,nacos-server 用的1.4.1的版本,我同时启动这2个服务,单独调用account-service时没有问题,但是我要通过gateway 调用时,就会出现404的错误,一开始我以为启动顺序的问题,然后我重启account-service,然后再通过网关来访问account, 这里有概率的事件,有的时候能访问成功,有的时候还是404,写了个demo可以复现: https://github.com/Taogang00/cloud.git

Expected behavior A clear and concise description of what you expected to happen.

通过网关访问服务成功,并且不应该有启动顺序的限制吧?记得之前eureka和consul 好像是没有限制的

Acutally behavior 404

How to Reproduce Steps to reproduce the behavior:

1.同时启动 gateway (端口9999)和 account(端口9001) 服务

2.单独调用account 服务:http://localhost:9001/guanwei-cloud-account-service/1 调用成功

3.通过gateway 调用account 服务 http://localhost:9999/guanwei-cloud-account-service/1 调用失败 404

4.重启account 服务,通过网关调用:有的时候调用成功,有的时候调用404

Desktop (please complete the following information):

Additional context

KomachiSion commented 3 years ago

单独调用没问题说明问题不是出在nacos上 而是出在gateway上。

gateway可能有缓存,导致没有及时刷新服务,或者有的版本gateway不去加载新出现的服务,只在启动时取一次服务列表, 新增的服务他不添加进去。

这些问题需要转到gateway取修复

Taogang00 commented 3 years ago

非nacos和gateway的问题,是我在配置routes 是有误~~ O(∩_∩)O

mchgood commented 3 years ago

非nacos和gateway的问题,是我在配置routes 是有误~~ O(∩_∩)O

你好,你是哪里配置出现了问题?我现在也遇到这种偶发情况

Crazykulou commented 2 years ago

非nacos和gateway的问题,是我在配置routes 是有误~~ O(∩_∩)O

你好,你是哪里配置出现了问题?我现在也遇到这种偶发情况

最近遇到了,发现配置并没有问题,而是开发的时候实例名重复了,但Server不是同一个,最后导致了偶尔出现404的问题,完全是自身原因。