Skip to content

When nacos client use endpoint, the registration center should support configuring context-path and cluster-name like the configuration center #10792

@huhongjie2014

Description

@huhongjie2014

Describe the bug
When nacos clients use nacos endpoint, the registration center should support configuring context-path and cluster-name like the configuration center
当nacos client使用endpoint时,注册中心应该像配置中心一样支持配置 context-path and cluster-name

When I use the following configuration, application launch failed, please note that I am using the nacos endpoint.
当我使用如下配置时,程序启动失败,请注意我使用了 nacos endpoint

spring:
  application:
    name: test-service
  profiles:
    active: dev
  cloud:
    nacos:
      config:
        endpoint: localhost:8080
        context-path: /nacos
        cluster-name: china
        namespace:
        username: nacos
        password: nacos
        group: test
      discovery:
        endpoint: localhost:8080
        context-path: /nacos
        cluster-name: china
        namespace:
        username: nacos
        password: nacos
        group: test

configuration center - The address is correct
配置中心 - 地址正确

com.alibaba.nacos.client.config.impl.ServerListManager#initAddressServerUrl
private void initAddressServerUrl(NacosClientProperties properties) {
        ...
        StringBuilder addressServerUrlTem = new StringBuilder(
                String.format("http://%s:%d%s/%s", this.endpoint, this.endpointPort,
                        ContextPathUtil.normalizeContextPath(this.contentPath), this.serverListName));
        ...
    }

addressServerUrlTem=http://localhost:8080/nacos/china      

registration center - The address is incorrect
注册中心 - 地址错误

com.alibaba.nacos.client.naming.core.ServerListManager#getServerListFromEndpoint
private List<String> getServerListFromEndpoint() {
        ...
        // Hard coded, configuration not supported  此处硬编码,不支持配置
        String urlString = HTTP_PREFIX + endpoint + "/nacos/serverlist";
        ...
}
urlString=http://localhost:8080/nacos/serverlist

Expected behavior
When nacos client use endpoint, the registration center should support configuring context-path and cluster-name like the configuration center
当nacos client使用endpoint时,注册中心应该像配置中心一样支持配置 context-path and cluster-name

Actually behavior
When nacos client use endpoint, the registration center not support configuring context-path and cluster-name
当nacos client使用endpoint时,注册中心不支持配置 context-path and cluster-name

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/ClientRelated to Nacos Client SDKkind/enhancementCategory issues or prs related to enhancement.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions