alibaba / spring-cloud-alibaba

Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.
https://sca.aliyun.com
Apache License 2.0
27.95k stars 8.34k forks source link

dubbo + spring cloud 启动warning #1151

Closed runzexia closed 4 years ago

runzexia commented 4 years ago
2019-12-31 13:58:22  WARN [employee-service,,,]  [DUBBO] Connection refused (Connection refused), dubbo version: 2.7.3, current host: 192.168.196.214
java.net.ConnectException: Connection refused (Connection refused)
    at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_181]
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_181]
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_181]
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_181]
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_181]
    at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_181]
    at org.apache.dubbo.config.ServiceConfig.findConfigedHosts(ServiceConfig.java:698) [dubbo-2.7.3.jar:2.7.3]
    at org.apache.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:560) [dubbo-2.7.3.jar:2.7.3]
    at org.apache.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:457) [dubbo-2.7.3.jar:2.7.3]
    at org.apache.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:415) [dubbo-2.7.3.jar:2.7.3]
    at org.apache.dubbo.config.ServiceConfig.export(ServiceConfig.java:378) [dubbo-2.7.3.jar:2.7.3]
    at org.apache.dubbo.config.spring.ServiceBean.export(ServiceBean.java:336) [dubbo-2.7.3.jar:2.7.3]
    at org.apache.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:114) [dubbo-2.7.3.jar:2.7.3]
    at org.apache.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:60) [dubbo-2.7.3.jar:2.7.3]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) [spring-context-5.1.12.RELEASE.jar:5.1.12.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) [spring-context-5.1.12.RELEASE.jar:5.1.12.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) [spring-context-5.1.12.RELEASE.jar:5.1.12.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:402) [spring-context-5.1.12.RELEASE.jar:5.1.12.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:359) [spring-context-5.1.12.RELEASE.jar:5.1.12.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:896) [spring-context-5.1.12.RELEASE.jar:5.1.12.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:162) [spring-boot-2.1.11.RELEASE.jar:2.1.11.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552) [spring-context-5.1.12.RELEASE.jar:5.1.12.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) [spring-boot-2.1.11.RELEASE.jar:2.1.11.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744) [spring-boot-2.1.11.RELEASE.jar:2.1.11.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391) [spring-boot-2.1.11.RELEASE.jar:2.1.11.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) [spring-boot-2.1.11.RELEASE.jar:2.1.11.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.1.11.RELEASE.jar:2.1.11.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204) [spring-boot-2.1.11.RELEASE.jar:2.1.11.RELEASE]
    at io.kubesphere.services.employee.EmployeeApplication.main(EmployeeApplication.java:25) [classes/:na]
spring:
  application:
    name: employee-service
  cloud:
    nacos:
      config:
        server-addr: localhost:8848
        file-extension: yaml
dubbo:
  scan:
    base-packages: io.kubesphere.services.employee
  protocols:
    dubbo:
      name: dubbo
    rest:
      name: rest
      port: ${PORT:8090}
      server: tomcat
  registry:
    #   The Spring Cloud Dubbo's registry extension
    address: nacos://localhost:8848
    address: springcloud://localhost   #上下两种配置都会有warning,但是服务都可以调用成功,不知道是不是哪里配置的有问题
    <dependencies>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-sleuth</artifactId>
        </dependency>
        <dependency>
            <groupId>io.kubesphere.services</groupId>
            <artifactId>api</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-dubbo</artifactId>
        </dependency>
    </dependencies>

nacos config:

server:
  port: ${PORT:8090}
logging:
  pattern:
    console: "%d{yyyy-MM-dd HH:mm:ss} ${LOG_LEVEL_PATTERN:-%5p} %m%n"
spring:
  cloud:
    nacos:
      discovery:
        server-addr: localhost:8848
yuhuangbin commented 4 years ago

The latest version does not need to configure dubbo.registry.address , But if you need to do this, Please refer to dubbo.registry.address=spring-cloud://localhost

runzexia commented 4 years ago

Thanks a lot for the quick reply. I have similar errors when I set dubbo.registry.address=spring-cloud://localhost @yuhuangbin

yuhuangbin commented 4 years ago

Thanks a lot for the quick reply. I have similar errors when I set dubbo.registry.address=spring-cloud://localhost @yuhuangbin

In my local, it works well

runzexia commented 4 years ago

Thanks a lot for the quick reply. I have similar errors when I set dubbo.registry.address=spring-cloud://localhost @yuhuangbin

In my local, it works well

https://github.com/runzexia/spring-microservices-sample/tree/alibaba-dubbo I set up the project as a public project, this is a springcloud and dubbo demo. You can try run employee-service, it does not depend on any service. The configuration in nacos is saved in this file, you need to create it in nacos https://github.com/runzexia/spring-microservices-sample/blob/alibaba-dubbo/employee-service/nacos-config.yaml

yuhuangbin commented 4 years ago

看了你的项目,觉得你使用nacos作为配置中心写的有点问题,建议你参考下官方demo. 或者参考下spring-cloud-alibaba-samples

runzexia commented 4 years ago

检查了一下没发现哪里有问题,我进debug模式看是要连 127.0.0.1:9090 这个地址,没有配置有关这个地址呀,有时间的时候可以帮忙看下嘛?

runzexia commented 4 years ago

我把employee-service的nacos-config关掉了,现在试了下仍然会报错。 启动配置已经简化了很多。 https://github.com/runzexia/spring-microservices-sample/blob/alibaba-dubbo-warnshow/employee-service/src/main/resources/bootstrap.yml

runzexia commented 4 years ago

ref https://github.com/alibaba/spring-cloud-alibaba/issues/915 cc @fangjian0423

runzexia commented 4 years ago

发现问题是在连接vpn的本地机器,server启动在不同的hosts。 在非vpn环境的linux机器正常

RichardKyire commented 3 years ago

发现问题是在连接vpn的本地机器,server启动在不同的hosts。 在非vpn环境的linux机器正常

我出现和你一样的问题,本地我关了vpn还是不行,同样发现是会连 127.0.0.1:9090 不知道这个是什么地址,你本地解决了嘛?

Flytan commented 3 years ago

手动指定本机的host