当前位置:   article > 正文

Failed to bind NettyServer on /192.168.**.*:20880, cause: Failed to bind to: /0.0.0.0:20880_failed to bind nettyserver on /0.0.0.0:20880, caus

failed to bind nettyserver on /0.0.0.0:20880, cause: address already in use:

一、概述

今天遇到的Dubbo的问题,做项目的时候,在做Dubbo的多个模块调用dubbo服务的时候遇到的问题,下面是这个问题和解决方案

二、问题异常消息

  Failed to bind NettyServer on /192.168.128.1:20880, cause: Failed to bind to: /0.0.0.0:20880  
        at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol.createServer(DubboProtocol.java:289)  
        at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol.openServer(DubboProtocol.java:266)  
        at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol.export(DubboProtocol.java:253)  
        at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:55)  
        at com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:56)  
        at com.alibaba.dubbo.rpc.Protocol$Adpative.export(Protocol$Adpative.java)  
        at com.alibaba.dubbo.registry.integration.RegistryProtocol.doLocalExport(RegistryProtocol.java:153)  
        at com.alibaba.dubbo.registry.integration.RegistryProtocol.export(RegistryProtocol.java:107)  
        at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:53)  
        at com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:54)  
        at com.alibaba.dubbo.rpc.Protocol$Adpative.export(Protocol$Adpative.java)  
        at com.alibaba.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:485)  
        at com.alibaba.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:281)  
        at com.alibaba.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:242)  
        at com.alibaba.dubbo.config.ServiceConfig.export(ServiceConfig.java:143)  
        at com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:109)  
        at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:163)  
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:136)  
        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:381)  
        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:335)  
        at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:855)  
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541)  
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)  
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)  
        at com.tgb.qmx.demo.dubbo.provider.Provider.main(Provider.java:8)  
    Caused by: com.alibaba.dubbo.remoting.RemotingException: Failed to bind NettyServer on /192.168.56.1:20880, cause: Failed to bind to: /0.0.0.0:20880  
        at com.alibaba.dubbo.remoting.transport.AbstractServer.<init>(AbstractServer.java:72)  
        at com.alibaba.dubbo.remoting.transport.netty.NettyServer.<init>(NettyServer.java:63)  
        at com.alibaba.dubbo.remoting.transport.netty.NettyTransporter.bind(NettyTransporter.java:33)  
        at com.alibaba.dubbo.remoting.Transporter$Adpative.bind(Transporter$Adpative.java)  
        at com.alibaba.dubbo.remoting.Transporters.bind(Transporters.java:48)  
        at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchanger.bind(HeaderExchanger.java:41)  
        at com.alibaba.dubbo.remoting.exchange.Exchangers.bind(Exchangers.java:63)  
        at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol.createServer(DubboProtocol.java:287)  
        ... 24 more  
    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)  
        at com.alibaba.dubbo.remoting.transport.netty.NettyServer.doOpen(NettyServer.java:94)  
        at com.alibaba.dubbo.remoting.transport.AbstractServer.<init>(AbstractServer.java:67)2016-08-07 21:47:25,015 INFO [com.alibaba.dubbo.config.AbstractConfig] -  [DUBBO] Run shutdown hook now., dubbo version: 2.5.3, current host: 127.0.0.1  
   
   Caused by: java.net.BindException: Address already in use: bind  
        at sun.nio.ch.Net.bind0(Native Method)  
        at sun.nio.ch.Net.bind(Net.java:414)  
        at sun.nio.ch.Net.bind(Net.java:406)  
        at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)  
        at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)  
        at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.bind(NioServerSocketPipelineSink.java:148)  
        at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.handleServerSocket(NioServerSocketPipelineSink.java:100)  
        at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.eventSunk(NioServerSocketPipelineSink.java:74)  
        at org.jboss.netty.channel.Channels.bind(Channels.java:468)  
        at org.jboss.netty.channel.AbstractChannel.bind(AbstractChannel.java:192)  
        at org.jboss.netty.bootstrap.ServerBootstrap$Binder.channelOpen(ServerBootstrap.java:348)  
        at org.jboss.netty.channel.Channels.fireChannelOpen(Channels.java:176)  
        at org.jboss.netty.channel.socket.nio.NioServerSocketChannel.<init>(NioServerSocketChannel.java:85)  
        at org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory.newChannel(NioServerSocketChannelFactory.java:142)  
        at org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory.newChannel(NioServerSocketChannelFactory.java:90)  
        at org.jboss.netty.bootstrap.ServerBootstrap.bind(ServerBootstrap.java:282)  
        ... 33 more  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59

其实,我们看代码的话,就可以看到,是地址别占用的问题,我们使用的端口号是20880,说明,20880端口已经被占用了。

三、解决方案

1、我们看Zookeeper的注册中心查找到了已经有提供者占用了20880端口:

这里写图片描述

因为我们每次发布一个系统,那么该系统的所有的提供者,就占用了20880端口。

2、因此,如果我们,再写一个系统,该系统的dubbo-provider中写的20880

这里写图片描述

3、这个时候,就会报上面的错误,也就是20880端口被一个系统已经占用了,因此,这个提供者的端口,就要换一个了,换一个就随便一个没有被占用的端口就可以了。
这里写图片描述

4、这样,我们运行一下provider就不会报错了。
这里写图片描述

四、总结

在有多个模块提供服务和多个模块调用服务时,每一个服务都会占用一个端口,所有,有多个模块时,每个模块的端口应该设置为不一样才可以。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/165984
推荐阅读
相关标签
  

闽ICP备14008679号