Sentinel icon indicating copy to clipboard operation
Sentinel copied to clipboard

网关限流添加api分组后无法找到服务

Open q876625596 opened this issue 2 years ago • 3 comments

Issue Description

Type: bug report

Describe what happened (or what feature you want)

当我没有在网关添加api分组的时候,一切正常, 当我在网关中添加了api分组,启动网关之后,控制台无法看到网关服务。 When I did not add an API group to the gateway, everything was normal, When I add an api group to the gateway and start the gateway, the dashboard cannot see the gateway service.

这是我在GatewayConfig中添加的api分组 This is the api group I added in GatewayConfig

    @PostConstruct
    public void doInit() {
        initCustomizedApis();
    }

    private void initCustomizedApis() {
        Set<ApiDefinition> definitions = new HashSet<>();
        ApiDefinition api1 = new ApiDefinition("custom_system")
                .setPredicateItems(new HashSet<ApiPredicateItem>() {{
                    add(new ApiPathPredicateItem().setPattern("/system/sysUser/list"));
                    add(new ApiPathPredicateItem().setPattern("/system/sysOnline/**")
                            .setMatchStrategy(SentinelGatewayConstants.URL_MATCH_STRATEGY_PREFIX));
                }});
        definitions.add(api1);
        GatewayApiDefinitionManager.loadApiDefinitions(definitions);
    }

Describe what you expected to happen

How to reproduce it (as minimally and precisely as possible)

  1. sentinel version 1.8.5
  2. spring cloud alibaba version 2021.0.4.0
  3. fastjson version 2.0.10
  4. jdk version 1.8
  5. 其他配置和文档一致(Other configurations are consistent with the documents)

Tell us your environment

Windows11

Anything else we need to know?

q876625596 avatar Jan 07 '23 16:01 q876625596

确认网关有触发正常访问,相关排查可参考 FAQ.

sczyh30 avatar Jan 11 '23 01:01 sczyh30

遇到同样的问题,请问最后是怎么解决的

ginwAa avatar Sep 05 '23 02:09 ginwAa

同样的问题,调用 GatewayApiDefinitionManager.loadApiDefinitions(definitions);后就失效。 且在http://ip:port/actuator/sentinel中,查不到信息。 不调用时,actuator中显示如下: image

调用后显示显示如下: image

shuaiho avatar Oct 27 '23 07:10 shuaiho