dubbo icon indicating copy to clipboard operation
dubbo copied to clipboard

不使用dubbo的默认日志框架,启动时会报拒绝连接错误

Open longzhaobi opened this issue 5 years ago • 2 comments

  • [ ] I have searched the issues of this repository and believe that this is not a duplicate.
  • [ ] I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

  • Dubbo version: 2.7.8
  • Operating System version: deepin V20 社区版
  • Java version: 1.8

Steps to reproduce this issue

  1. 在springboot启动main方法里添加如下代码:
System.setProperty("dubbo.application.logger","slf4j");

Pls. provide [GitHub address] to reproduce this issue.

Expected Result

希望项目启动时不要报异常

Actual Result

如果使用dubbo的默认日志框架启动时不会报任何错误。 使用了指定的slf4j就会报如下异常,但并不影响使用。

为了不看见异常,我暂时使用默认的log4j

2020-12-26 19:01:40.203  INFO 10072 --- [           main] org.apache.dubbo.config.ServiceConfig    :  [DUBBO] Export dubbo service com.zbi.admin.service.PermissionService to local registry url : injvm://127.0.0.1/com.zbi.admin.service.PermissionService?anyhost=true&application=zbi-admin-server&bind.ip=192.168.31.90&bind.port=20880&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&group=permissionServiceImpl&interface=com.zbi.admin.service.PermissionService&logger=slf4j&methods=query,update,del,delete,queryList,queryColumns,findPermissionByIds,queryById&pid=10072&qos.enable=false&release=2.7.8&side=provider&timestamp=1608980500199, dubbo version: 2.7.8, current host: 192.168.31.90
2020-12-26 19:01:40.203  INFO 10072 --- [           main] org.apache.dubbo.config.ServiceConfig    :  [DUBBO] Register dubbo service com.zbi.admin.service.PermissionService url dubbo://192.168.31.90:20880/com.zbi.admin.service.PermissionService?anyhost=true&application=zbi-admin-server&bind.ip=192.168.31.90&bind.port=20880&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&group=permissionServiceImpl&interface=com.zbi.admin.service.PermissionService&logger=slf4j&methods=query,update,del,delete,queryList,queryColumns,findPermissionByIds,queryById&pid=10072&qos.enable=false&release=2.7.8&side=provider&timestamp=1608980500199 to registry registry://localhost:9090/org.apache.dubbo.registry.RegistryService?application=zbi-admin-server&dubbo=2.0.2&logger=slf4j&pid=10072&qos.enable=false&registry=spring-cloud&release=2.7.8&timestamp=1608980500199, dubbo version: 2.7.8, current host: 192.168.31.90
2020-12-26 19:01:40.204  INFO 10072 --- [           main] c.a.c.dubbo.registry.DubboCloudRegistry  :  [DUBBO] Register: dubbo://192.168.31.90:20880/com.zbi.admin.service.PermissionService?anyhost=true&application=zbi-admin-server&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&group=permissionServiceImpl&interface=com.zbi.admin.service.PermissionService&logger=slf4j&methods=query,update,del,delete,queryList,queryColumns,findPermissionByIds,queryById&pid=10072&release=2.7.8&side=provider&timestamp=1608980500199, dubbo version: 2.7.8, current host: 192.168.31.90
2020-12-26 19:01:40.205  INFO 10072 --- [           main] c.a.c.dubbo.registry.DubboCloudRegistry  :  [DUBBO] Subscribe: provider://192.168.31.90:20880/com.zbi.admin.service.PermissionService?anyhost=true&application=zbi-admin-server&bind.ip=192.168.31.90&bind.port=20880&category=configurators&check=false&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&group=permissionServiceImpl&interface=com.zbi.admin.service.PermissionService&logger=slf4j&methods=query,update,del,delete,queryList,queryColumns,findPermissionByIds,queryById&pid=10072&qos.enable=false&release=2.7.8&side=provider&timestamp=1608980500199, dubbo version: 2.7.8, current host: 192.168.31.90
2020-12-26 19:01:40.206  INFO 10072 --- [           main] m.DynamicConfigurationServiceNameMapping :  [DUBBO] Dubbo service[permissionServiceImpl] mapped to interface name[com.zbi.admin.service.PermissionService]., dubbo version: 2.7.8, current host: 192.168.31.90
2020-12-26 19:01:40.213  INFO 10072 --- [           main] org.apache.dubbo.config.ServiceConfig    :  [DUBBO] No valid ip found from environment, try to find valid host from DNS., dubbo version: 2.7.8, current host: 192.168.31.90
2020-12-26 19:01:40.213  WARN 10072 --- [           main] org.apache.dubbo.config.ServiceConfig    :  [DUBBO] 拒绝连接, dubbo version: 2.7.8, current host: 192.168.31.90

java.net.ConnectException: 拒绝连接
	at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_60]
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_60]
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_60]
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_60]
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_60]
	at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_60]
	at org.apache.dubbo.config.ServiceConfig.findConfigedHosts(ServiceConfig.java:588) [dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:443) [dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:325) [dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:300) [dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.ServiceConfig.export(ServiceConfig.java:206) [dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.bootstrap.DubboBootstrap.lambda$exportServices$15(DubboBootstrap.java:1103) [dubbo-2.7.8.jar:2.7.8]
	at java.util.HashMap$Values.forEach(HashMap.java:972) ~[na:1.8.0_60]
	at org.apache.dubbo.config.bootstrap.DubboBootstrap.exportServices(DubboBootstrap.java:1090) [dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.bootstrap.DubboBootstrap.start(DubboBootstrap.java:901) [dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onContextRefreshedEvent(DubboBootstrapApplicationListener.java:59) ~[dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onApplicationContextEvent(DubboBootstrapApplicationListener.java:52) ~[dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.spring.context.OneTimeExecutionApplicationContextEventListener.onApplicationEvent(OneTimeExecutionApplicationContextEventListener.java:40) ~[dubbo-2.7.8.jar:2.7.8]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:404) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:361) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:898) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:162) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:554) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at com.zbi.admin.AdminServerApplication.main(AdminServerApplication.java:32) ~[classes/:na]

longzhaobi avatar Dec 26 '20 11:12 longzhaobi

  • [ ] I have searched the issues of this repository and believe that this is not a duplicate.
  • [ ] I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

  • Dubbo version: 2.7.8
  • Operating System version: deepin V20 社区版
  • Java version: 1.8

Steps to reproduce this issue

  1. 在springboot启动main方法里添加如下代码:
System.setProperty("dubbo.application.logger","slf4j");

Pls. provide [GitHub address] to reproduce this issue.

Expected Result

希望项目启动时不要报异常

Actual Result

如果使用dubbo的默认日志框架启动时不会报任何错误。 使用了指定的slf4j就会报如下异常,但并不影响使用。

为了不看见异常,我暂时使用默认的log4j

2020-12-26 19:01:40.203  INFO 10072 --- [           main] org.apache.dubbo.config.ServiceConfig    :  [DUBBO] Export dubbo service com.zbi.admin.service.PermissionService to local registry url : injvm://127.0.0.1/com.zbi.admin.service.PermissionService?anyhost=true&application=zbi-admin-server&bind.ip=192.168.31.90&bind.port=20880&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&group=permissionServiceImpl&interface=com.zbi.admin.service.PermissionService&logger=slf4j&methods=query,update,del,delete,queryList,queryColumns,findPermissionByIds,queryById&pid=10072&qos.enable=false&release=2.7.8&side=provider&timestamp=1608980500199, dubbo version: 2.7.8, current host: 192.168.31.90
2020-12-26 19:01:40.203  INFO 10072 --- [           main] org.apache.dubbo.config.ServiceConfig    :  [DUBBO] Register dubbo service com.zbi.admin.service.PermissionService url dubbo://192.168.31.90:20880/com.zbi.admin.service.PermissionService?anyhost=true&application=zbi-admin-server&bind.ip=192.168.31.90&bind.port=20880&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&group=permissionServiceImpl&interface=com.zbi.admin.service.PermissionService&logger=slf4j&methods=query,update,del,delete,queryList,queryColumns,findPermissionByIds,queryById&pid=10072&qos.enable=false&release=2.7.8&side=provider&timestamp=1608980500199 to registry registry://localhost:9090/org.apache.dubbo.registry.RegistryService?application=zbi-admin-server&dubbo=2.0.2&logger=slf4j&pid=10072&qos.enable=false&registry=spring-cloud&release=2.7.8&timestamp=1608980500199, dubbo version: 2.7.8, current host: 192.168.31.90
2020-12-26 19:01:40.204  INFO 10072 --- [           main] c.a.c.dubbo.registry.DubboCloudRegistry  :  [DUBBO] Register: dubbo://192.168.31.90:20880/com.zbi.admin.service.PermissionService?anyhost=true&application=zbi-admin-server&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&group=permissionServiceImpl&interface=com.zbi.admin.service.PermissionService&logger=slf4j&methods=query,update,del,delete,queryList,queryColumns,findPermissionByIds,queryById&pid=10072&release=2.7.8&side=provider&timestamp=1608980500199, dubbo version: 2.7.8, current host: 192.168.31.90
2020-12-26 19:01:40.205  INFO 10072 --- [           main] c.a.c.dubbo.registry.DubboCloudRegistry  :  [DUBBO] Subscribe: provider://192.168.31.90:20880/com.zbi.admin.service.PermissionService?anyhost=true&application=zbi-admin-server&bind.ip=192.168.31.90&bind.port=20880&category=configurators&check=false&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&group=permissionServiceImpl&interface=com.zbi.admin.service.PermissionService&logger=slf4j&methods=query,update,del,delete,queryList,queryColumns,findPermissionByIds,queryById&pid=10072&qos.enable=false&release=2.7.8&side=provider&timestamp=1608980500199, dubbo version: 2.7.8, current host: 192.168.31.90
2020-12-26 19:01:40.206  INFO 10072 --- [           main] m.DynamicConfigurationServiceNameMapping :  [DUBBO] Dubbo service[permissionServiceImpl] mapped to interface name[com.zbi.admin.service.PermissionService]., dubbo version: 2.7.8, current host: 192.168.31.90
2020-12-26 19:01:40.213  INFO 10072 --- [           main] org.apache.dubbo.config.ServiceConfig    :  [DUBBO] No valid ip found from environment, try to find valid host from DNS., dubbo version: 2.7.8, current host: 192.168.31.90
2020-12-26 19:01:40.213  WARN 10072 --- [           main] org.apache.dubbo.config.ServiceConfig    :  [DUBBO] 拒绝连接, dubbo version: 2.7.8, current host: 192.168.31.90

java.net.ConnectException: 拒绝连接
	at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_60]
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_60]
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_60]
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_60]
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_60]
	at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_60]
	at org.apache.dubbo.config.ServiceConfig.findConfigedHosts(ServiceConfig.java:588) [dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:443) [dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:325) [dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:300) [dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.ServiceConfig.export(ServiceConfig.java:206) [dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.bootstrap.DubboBootstrap.lambda$exportServices$15(DubboBootstrap.java:1103) [dubbo-2.7.8.jar:2.7.8]
	at java.util.HashMap$Values.forEach(HashMap.java:972) ~[na:1.8.0_60]
	at org.apache.dubbo.config.bootstrap.DubboBootstrap.exportServices(DubboBootstrap.java:1090) [dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.bootstrap.DubboBootstrap.start(DubboBootstrap.java:901) [dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onContextRefreshedEvent(DubboBootstrapApplicationListener.java:59) ~[dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onApplicationContextEvent(DubboBootstrapApplicationListener.java:52) ~[dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.spring.context.OneTimeExecutionApplicationContextEventListener.onApplicationEvent(OneTimeExecutionApplicationContextEventListener.java:40) ~[dubbo-2.7.8.jar:2.7.8]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:404) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:361) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:898) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:162) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:554) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at com.zbi.admin.AdminServerApplication.main(AdminServerApplication.java:32) ~[classes/:na]

longzhaobi avatar Dec 28 '20 13:12 longzhaobi

有个办法解决,你可以参考一下 在dubbo的配置中,目前(2021年11月23日16:31:34)的版本,在使用springcloud的discovery的时候 是可以不用配置registry.address的,但是你可以加上这个配置,配置如下,配置成内网IP,就看不到报错了,你看看能不能解决你的问题。

dubbo:
  cloud:
    subscribed-services: ${spring.application.name}
  scan:
    base-packages: com.example
  protocol:
    name: dubbo
    port: 20880
  registry:
    address: spring-cloud://_**这里写内网IP**_

imyiren avatar Nov 23 '21 08:11 imyiren