Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WARN org.apache.dubbo.config.ServiceConfig.findConfigedHost #13447

Closed
896938034 opened this issue Nov 30, 2023 · 2 comments
Closed

WARN org.apache.dubbo.config.ServiceConfig.findConfigedHost #13447

896938034 opened this issue Nov 30, 2023 · 2 comments
Labels
status/waiting-for-feedback Need reporters to triage

Comments

@896938034
Copy link
Contributor

896938034 commented Nov 30, 2023

Environment

  • Dubbo version: 2.7.8
  • nacos version: 1.4.0
  • springboot version: 2.3.0.RELEASE
  • Operating System version: macos
  • Java version: 1.8

Steps to reproduce this issue

  1. Problem description
    nacos requires that the addresses of multiple registration centers be separated by English commas, and dubbo requires that the addresses of the registration centers be separated by English semicolons; when dubbo uses nacos as the registration center, a WARN error "org.apache" will be reported during the project startup process. .dubbo.config.ServiceConfig.findConfigedHosts"; the reason for this error is that dubbo needs to establish a socket connection with the nacos registration center during the process of exposing the service and use the local address of this connection as the dubbo provider's ip. When parsing the registration center address The following code is used:
Pattern REGISTRY_SPLIT_PATTERN = Pattern.compile("\\s*[|;]+\\s*");

String[] addresses = REGISTRY_SPLIT_PATTERN.split(address);

The address parsed by this end of the code is "192.168.10.10, 192.168.10.11, 192.168.10.12". When using this address new InetSocketAddress, an error was reported, but a warn log was caught. The specific code is as follows

try (Socket socket = new Socket()) {
     SocketAddress addr = new InetSocketAddress(registryURL.getHost(), registryURL.getPort());
     socket.connect(addr, 1000);
     hostToBind = socket.getLocalAddress().getHostAddress();
     break;
} catch (Exception e) {
     logger.warn(e.getMessage(), e);
}
In this way, in the case of multiple network cards, it is impossible to obtain the correct IP address to expose the service.

2.Exception stack

   WARN org.apache.dubbo.config.ServiceConfig.findConfigedHosts:592 - [DUBBO] 192.168.41.3:8848,192.168.41.9:8848,192.168.41.14, dubbo version: 2.7.8, current host: 10.2.19.204
java.net.UnknownHostException: 192.168.41.3:8848,192.168.41.9:8848,192.168.41.14
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:196)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:394)
at java.net.Socket.connect(Socket.java:606)
at org.apache.dubbo.config.ServiceConfig.findConfigedHosts(ServiceConfig.java:588)
at org.apache.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:443)
at org.apache.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:325)
at org.apache.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:300)
at org.apache.dubbo.config.ServiceConfig.export(ServiceConfig.java:206)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.lambda$exportServices$15(DubboBootstrap.java:1103)
at java.util.HashMap$Values.forEach(HashMap.java:983)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.exportServices(DubboBootstrap.java:1090)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.start(DubboBootstrap.java:901)
at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onContextRefreshedEvent(DubboBootstrapApplicationListener.java:59)
at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onApplicationContextEvent(DubboBootstrapApplicationListener.java:52)
at org.apache.dubbo.config.spring.context.OneTimeExecutionApplicationContextEventListener.onApplicationEvent(OneTimeExecutionApplicationContextEventListener.java:40)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:403)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:360)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:897)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at net.xxx.Xxx.Application.run(XxxSpringApplication.java:40)
at net.xxx.Xxx.Application.run(XxxSpringApplication.java:36)
at com.xxx.Application.main(Application.java:16)
  1. Involved classes or methods
org.apache.dubbo.config.ServiceConfig#findConfigedHosts
com.alibaba.nacos.client.config.impl.ServerListManager#ServerListManager(java.util.Properties)
  1. Modification suggestions
    It is recommended that the regular expression in the dubbo parsing registration center be compatible with English commas

  1. 问题描述
    nacos要求多个注册中心的地址用英文的逗号分割,dubbo要求注册中心的地址用英文的分号分割;当dubbo用nacos做注册中心时在项目启动过称中会报一个WARN错误 “org.apache.dubbo.config.ServiceConfig.findConfigedHosts”;这个错误产生的原因是dubbo在暴露服务的过程中要和nacos注册中心建立一个socket连接并用这个连接的本地地址作为dubbo提供者的ip,在解析注册中心地址时用到了下面的代码:
Pattern REGISTRY_SPLIT_PATTERN = Pattern.compile("\\s*[|;]+\\s*");

String[] addresses = REGISTRY_SPLIT_PATTERN.split(address);

这端代码解析出来的address为“192.168.10.10,192.168.10.11,192.168.10.12”,在用这个地址 new InetSocketAddress时报了一个错,但是被catch住打了一个warn日志具体代码快如下

try (Socket socket = new Socket()) {
    SocketAddress addr = new InetSocketAddress(registryURL.getHost(), registryURL.getPort());
    socket.connect(addr, 1000);
    hostToBind = socket.getLocalAddress().getHostAddress();
    break;
} catch (Exception e) {
    logger.warn(e.getMessage(), e);
}

这样在多网卡的情况下就无法获取正确的ip地址暴露服务了。

2.异常堆栈

  WARN  org.apache.dubbo.config.ServiceConfig.findConfigedHosts:592 -  [DUBBO] 192.168.41.3:8848,192.168.41.9:8848,192.168.41.14, dubbo version: 2.7.8, current host: 10.2.19.204
java.net.UnknownHostException: 192.168.41.3:8848,192.168.41.9:8848,192.168.41.14
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:196)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:394)
	at java.net.Socket.connect(Socket.java:606)
	at org.apache.dubbo.config.ServiceConfig.findConfigedHosts(ServiceConfig.java:588)
	at org.apache.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:443)
	at org.apache.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:325)
	at org.apache.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:300)
	at org.apache.dubbo.config.ServiceConfig.export(ServiceConfig.java:206)
	at org.apache.dubbo.config.bootstrap.DubboBootstrap.lambda$exportServices$15(DubboBootstrap.java:1103)
	at java.util.HashMap$Values.forEach(HashMap.java:983)
	at org.apache.dubbo.config.bootstrap.DubboBootstrap.exportServices(DubboBootstrap.java:1090)
	at org.apache.dubbo.config.bootstrap.DubboBootstrap.start(DubboBootstrap.java:901)
	at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onContextRefreshedEvent(DubboBootstrapApplicationListener.java:59)
	at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onApplicationContextEvent(DubboBootstrapApplicationListener.java:52)
	at org.apache.dubbo.config.spring.context.OneTimeExecutionApplicationContextEventListener.onApplicationEvent(OneTimeExecutionApplicationContextEventListener.java:40)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:403)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:360)
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:897)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
	at net.xxx.Xxx.Application.run(XxxSpringApplication.java:40)
	at net.xxx.Xxx.Application.run(XxxSpringApplication.java:36)
	at com.xxx.Application.main(Application.java:16)

3.涉及到的类或方法

org.apache.dubbo.config.ServiceConfig#findConfigedHosts
com.alibaba.nacos.client.config.impl.ServerListManager#ServerListManager(java.util.Properties)

4.修改建议
建议在dubbo解析注册中心的正则表达式中兼容英文逗号的情况

@896938034 896938034 added the type/bug Bugs to being fixed label Nov 30, 2023
@AlbumenJ
Copy link
Member

AlbumenJ commented Dec 1, 2023

  1. It would be better to configure multi servers with dns name solution
  2. Dubbo is based on standard URL. Dubbo will not and will never support multi-host which is obey the standard of URL.

@CrazyHZM CrazyHZM added status/waiting-for-feedback Need reporters to triage and removed type/bug Bugs to being fixed labels Dec 22, 2023
@AlbumenJ
Copy link
Member

No news is good news. Please feel free to create a new issue if you have any question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/waiting-for-feedback Need reporters to triage
Projects
Archived in project
Development

No branches or pull requests

3 participants