问题描述

当我在使用Dubbo整合SpringBoot时,启动完成provider[提供者]的服务后,再依次启动consumer[消费者]的服务时,发现以下报错:

com.alibaba.dubbo.rpc.RpcException: Fail to start server(url: dubbo://192.168.194.1:20880/com.dream.gmall.service.OrderService?anyhost=true&application=order-service-consumer&bind.ip=192.168.194.1&bind.port=20880&channel.readonly.sent=true&codec=dubbo&dubbo=2.6.2&generic=false&heartbeat=60000&interface=com.dream.gmall.service.OrderService&methods=getAll,getAddress&monitor=dubbo%3A%2F%2F127.0.0.1%3A2181%2Fcom.alibaba.dubbo.registry.RegistryService%3Fapplication%3Dorder-service-consumer%26dubbo%3D2.6.2%26pid%3D12680%26protocol%3Dregistry%26refer%3Ddubbo%253D2.6.2%2526interface%253Dcom.alibaba.dubbo.monitor.MonitorService%2526pid%253D12680%2526timestamp%253D1562392202895%26registry%3Dzookeeper%26timestamp%3D1562392202827&pid=12680&side=provider&timestamp=1562392202829) Failed to bind NettyServer on /192.168.194.1:20880, cause: Failed to bind to: /0.0.0.0:20880
    at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol.createServer(DubboProtocol.java:286) ~[dubbo-2.6.2.jar:2.6.2]
    at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol.openServer(DubboProtocol.java:263) ~[dubbo-2.6.2.jar:2.6.2]
    at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol.export(DubboProtocol.java:250) ~[dubbo-2.6.2.jar:2.6.2]
    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:100) ~[dubbo-2.6.2.jar:2.6.2]
    at com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:57) ~[dubbo-2.6.2.jar:2.6.2]
    at com.alibaba.dubbo.qos.protocol.QosProtocolWrapper.export(QosProtocolWrapper.java:56) ~[dubbo-2.6.2.jar:2.6.2]
    at com.alibaba.dubbo.rpc.Protocol$Adaptive.export(Protocol$Adaptive.java) ~[dubbo-2.6.2.jar:2.6.2]
    at com.alibaba.dubbo.registry.integration.RegistryProtocol.doLocalExport(RegistryProtocol.java:168) ~[dubbo-2.6.2.jar:2.6.2]
    at com.alibaba.dubbo.registry.integration.RegistryProtocol.export(RegistryProtocol.java:131) ~[dubbo-2.6.2.jar:2.6.2]
    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:98) ~[dubbo-2.6.2.jar:2.6.2]
    at com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:55) ~[dubbo-2.6.2.jar:2.6.2]
    at com.alibaba.dubbo.qos.protocol.QosProtocolWrapper.export(QosProtocolWrapper.java:54) ~[dubbo-2.6.2.jar:2.6.2]
    at com.alibaba.dubbo.rpc.Protocol$Adaptive.export(Protocol$Adaptive.java) ~[dubbo-2.6.2.jar:2.6.2]
    at com.alibaba.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:506) ~[dubbo-2.6.2.jar:2.6.2]
    at com.alibaba.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:358) ~[dubbo-2.6.2.jar:2.6.2]
    at com.alibaba.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:317) ~[dubbo-2.6.2.jar:2.6.2]
    at com.alibaba.dubbo.config.ServiceConfig.export(ServiceConfig.java:216) ~[dubbo-2.6.2.jar:2.6.2]
    at com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:123) ~[dubbo-2.6.2.jar:2.6.2]
    at com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:49) ~[dubbo-2.6.2.jar:2.6.2]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:402) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:359) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:896) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:161) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:742) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:389) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
    at com.dream.gmall.OrderServiceConsumerApplication.main(OrderServiceConsumerApplication.java:11) [classes/:na]
Caused by: com.alibaba.dubbo.remoting.RemotingException: Failed to bind NettyServer on /192.168.194.1:20880, cause: Failed to bind to: /0.0.0.0:20880
    at com.alibaba.dubbo.remoting.transport.AbstractServer.<init>(AbstractServer.java:68) ~[dubbo-2.6.2.jar:2.6.2]
    at com.alibaba.dubbo.remoting.transport.netty.NettyServer.<init>(NettyServer.java:61) ~[dubbo-2.6.2.jar:2.6.2]
    at com.alibaba.dubbo.remoting.transport.netty.NettyTransporter.bind(NettyTransporter.java:32) ~[dubbo-2.6.2.jar:2.6.2]
    at com.alibaba.dubbo.remoting.Transporter$Adaptive.bind(Transporter$Adaptive.java) ~[dubbo-2.6.2.jar:2.6.2]
    at com.alibaba.dubbo.remoting.Transporters.bind(Transporters.java:56) ~[dubbo-2.6.2.jar:2.6.2]
    at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchanger.bind(HeaderExchanger.java:44) ~[dubbo-2.6.2.jar:2.6.2]
    at com.alibaba.dubbo.remoting.exchange.Exchangers.bind(Exchangers.java:70) ~[dubbo-2.6.2.jar:2.6.2]
    at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol.createServer(DubboProtocol.java:284) ~[dubbo-2.6.2.jar:2.6.2]
    ... 33 common frames omitted
Caused by: org.jboss.netty.channel.ChannelException: Failed to bind to: /0.0.0.0:20880
    at org.jboss.netty.bootstrap.ServerBootstrap.bind(ServerBootstrap.java:303) ~[netty-3.2.5.Final.jar:na]
    at com.alibaba.dubbo.remoting.transport.netty.NettyServer.doOpen(NettyServer.java:93) ~[dubbo-2.6.2.jar:2.6.2]
    at com.alibaba.dubbo.remoting.transport.AbstractServer.<init>(AbstractServer.java:63) ~[dubbo-2.6.2.jar:2.6.2]
    ... 40 common frames omitted
Caused by: java.net.BindException: Address already in use: bind
    at sun.nio.ch.Net.bind0(Native Method) ~[na:1.8.0_152]
    at sun.nio.ch.Net.bind(Net.java:433) ~[na:1.8.0_152]
    at sun.nio.ch.Net.bind(Net.java:425) ~[na:1.8.0_152]
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) ~[na:1.8.0_152]
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74) ~[na:1.8.0_152]
    at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.bind(NioServerSocketPipelineSink.java:148) ~[netty-3.2.5.Final.jar:na]
    at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.handleServerSocket(NioServerSocketPipelineSink.java:100) ~[netty-3.2.5.Final.jar:na]
    at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.eventSunk(NioServerSocketPipelineSink.java:74) ~[netty-3.2.5.Final.jar:na]
    at org.jboss.netty.channel.Channels.bind(Channels.java:468) ~[netty-3.2.5.Final.jar:na]
    at org.jboss.netty.channel.AbstractChannel.bind(AbstractChannel.java:192) ~[netty-3.2.5.Final.jar:na]
    at org.jboss.netty.bootstrap.ServerBootstrap$Binder.channelOpen(ServerBootstrap.java:348) ~[netty-3.2.5.Final.jar:na]
    at org.jboss.netty.channel.Channels.fireChannelOpen(Channels.java:176) ~[netty-3.2.5.Final.jar:na]
    at org.jboss.netty.channel.socket.nio.NioServerSocketChannel.<init>(NioServerSocketChannel.java:85) ~[netty-3.2.5.Final.jar:na]
    at org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory.newChannel(NioServerSocketChannelFactory.java:142) ~[netty-3.2.5.Final.jar:na]
    at org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory.newChannel(NioServerSocketChannelFactory.java:90) ~[netty-3.2.5.Final.jar:na]
    at org.jboss.netty.bootstrap.ServerBootstrap.bind(ServerBootstrap.java:282) ~[netty-3.2.5.Final.jar:na]
    ... 42 common frames omitted

检查了代码没有发现任何错误

解决方案

可以依次看到以下报错信息:

1. com.alibaba.dubbo.rpc.RpcException: Fail to start server  服务启动失败

2. Caused by: com.alibaba.dubbo.remoting.RemotingException: Failed to bind NettyServer on /192.168.194.1:20880, cause: Failed to bind to: /0.0.0.0:20880   绑定到本机的20880端口失败

3. Caused by: org.jboss.netty.channel.ChannelException: Failed to bind to: /0.0.0.0:20880  尝试将服务绑定到本机的20880端口失败

4. Caused by: java.net.BindException: Address already in use: bind   绑定的地址已经被使用

由此我们可以越来越明显地知道,问题出在服务器地址或者端口上,所以找到application.properites配置文件,将dubbo.protocol.port的端口号改为20881,如以下代码:

dubbo.application.name = order-service-consumer
server.port = 8081
dubbo.registry.protocol=zookeeper
dubbo.registry.address=127.0.0.1:2181
dubbo.scan.base-packages=com.dream.gmall.service.impl
dubbo.monitor.protocol=registry
dubbo.protocol.name=dubbo
dubbo.protocol.port=20881    ## 此处由20880修改为20881

最终服务可以启动成功

解决com.alibaba.dubbo.rpc.RpcException: Fail to start server(url: dubbo://192.168.194.1:20880/...报错方案相关推荐

  1. Dubbo:com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method 问题的解决

    QUESTION:Dubbo:com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method 问题的解决? ANSWER: 一.原因: ...

  2. com.alibaba.dubbo.rpc.RpcException: Failed to invoke remote method解决方法

    com.alibaba.dubbo.rpc.RpcException: Failed to invoke remote method解决方法 参考文章: (1)com.alibaba.dubbo.rp ...

  3. Dubbo:com.alibaba.dubbo.rpc.RpcException Failed to invoke the method 问题的解决

    QUESTION:Dubbo:com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method 问题的解决 ANSWER: 一.原因: 1 ...

  4. com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method list in the service com.dream.servic

    在启动项目的时候dubbo出现以下错误(大概是这样,一开始只是提示dubbo出错): DEBUG [http-bio-8080-exec-3] - DispatcherServlet with nam ...

  5. Dubbo错误排查:com.alibaba.dubbo.rpc.RpcException: Invoke remote method timeout

    一.错误信息 客户端错误: com.alibaba.dubbo.rpc.RpcException: Invoke remote method timeout. method: searchUser, ...

  6. com.alibaba.dubbo.rpc.RpcException: Forbid consumer 192.168.184.1 access service com.foreveross.syst

    前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家.点击跳转到教程. 报错如下: com.alibaba.dubbo.rpc.RpcException: Forbid c ...

  7. [TODO]com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method

    异常信息如下: 2018-10-30 20:00:50.230 ERROR  java.util.concurrent.ExecutionException: com.alibaba.dubbo.rp ...

  8. com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method XXX in the service

    问题log com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method getExpressGoldOrderCount in th ...

  9. com.alibaba.dubbo.rpc.RpcException: No provider available from registry。。。报错问题

    当我们项目配置dubbo并进行访问时,这时候如果后台报错 com.alibaba.dubbo.rpc.RpcException: No provider available from registry ...

最新文章

  1. 【JavaScript代码】使用JavaScript实现简单的区块链(签名+工作量证明机制)
  2. Increasing Subsequence (hard version)
  3. 【原创】如何找回source insight context window?(作者:gooogleman)
  4. Codeforces Round #726 (Div. 2) D. Deleting Divisors 博弈
  5. MongoTemplate 使用aggregate聚合查询
  6. Android学习笔记(十一)——将Fragment添加到Activity中以及参数传递
  7. 图片简单上色,花开花落云卷云舒。
  8. access中如何画斜线_三维并没有想象中那么难,思路清晰画图就简单
  9. 适应科技发展观的Steam教学实践
  10. 药易通显示rpc服务器不可用,药易通8825-8826日常问题语句归档教程方案.docx
  11. 用计算机打字英语,用来打字练习的英文文章
  12. excel中将两列交叉合并为一列
  13. 什么邮箱垃圾邮件少?邮箱反垃圾系统是什么?
  14. Java利用数组求某年某日某月是某年的第几天(数组)
  15. 以太坊区块链快速入门
  16. 估计标准误差syx_相关系数与估计标准误差的关系
  17. Java中关于空格遇到的一些问题
  18. 如何在启动时禁用Razer突触启动画面
  19. intrins.h文件解读
  20. 【数据分析应用】-财务数据分析指标讲解

热门文章

  1. 0欧姆电阻 电感与磁珠的选择
  2. C语言中函数的定义举例说明,C语言函数的定义与使用
  3. 从订外卖的角度来理解- 一个网页是如何到你手上的。
  4. 两个标签云动画效果小demo
  5. [C++程序设计](入门级题解) 校门外的树
  6. 最新图片在线加水印网页源码+亲测可用
  7. c和java的区别_论C语言和Java的区别
  8. java中集合怎么定义_Java集合系列(一):集合的定义及分类
  9. php擂台赛,清华校友擂台赛 尹祖江序盘失机 梁敬弘怒涛连胜
  10. decimal 的解释说明