Caused by: java.net.BindException: Address already in use: bind

项目中有若干微服务,挨个启动的时候,报错

com.alibaba.dubbo.rpc.RpcException: Fail to start server(url: dubbo://10.118.44.10:20860/com.sf.sfpp.download.service.DownloadService?anyhost=true&application=sfpp&channel.readonly.sent=true&codec=dubbo&dubbo=2.8.4&generic=false&heartbeat=60000&interface=com.sf.sfpp.download.service.DownloadService&loadbalance=roundrobin&methods=fetchDownloadByDownloadId,removeDownload,addDownload,fetchDownloadsByParentId,updateDownload&owner=862911_HashZhang&pid=7208&side=provider&timestamp=1491202042837) Failed to bind NettyServer on /10.118.44.10:20860, cause: Failed to bind to: /0.0.0.0:20860
    at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol.createServer(DubboProtocol.java:331)
    at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol.openServer(DubboProtocol.java:308)
    at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol.export(DubboProtocol.java:258)
    at com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:56)
    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:55)
    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.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:54)
    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:53)
    at com.alibaba.dubbo.rpc.Protocol$Adpative.export(Protocol$Adpative.java)
    at com.alibaba.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:489)
    at com.alibaba.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:285)
    at com.alibaba.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:246)
    at com.alibaba.dubbo.config.ServiceConfig.export(ServiceConfig.java:145)
    at com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:110)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:96)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:948)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
    at com.alibaba.dubbo.container.spring.SpringContainer.start(SpringContainer.java:50)
    at com.alibaba.dubbo.container.Main.main(Main.java:80)
    at DownloadServerStart.main(DownloadServerStart.java:10)
Caused by: com.alibaba.dubbo.remoting.RemotingException: Failed to bind NettyServer on /10.118.44.10:20860, cause: Failed to bind to: /0.0.0.0:20860
    at com.alibaba.dubbo.remoting.transport.AbstractServer.<init>(AbstractServer.java:73)
    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:329)
    ... 24 more
Caused by: org.jboss.netty.channel.ChannelException: Failed to bind to: /0.0.0.0:20860
    at org.jboss.netty.bootstrap.ServerBootstrap.bind(ServerBootstrap.java:272)
    at com.alibaba.dubbo.remoting.transport.netty.NettyServer.doOpen(NettyServer.java:94)
    at com.alibaba.dubbo.remoting.transport.AbstractServer.<init>(AbstractServer.java:68)
    ... 31 more
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:444)
    at sun.nio.ch.Net.bind(Net.java:436)
    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.NioServerBoss$RegisterTask.run(NioServerBoss.java:193)
    at org.jboss.netty.channel.socket.nio.AbstractNioSelector.processTaskQueue(AbstractNioSelector.java:366)
    at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:290)
    at org.jboss.netty.channel.socket.nio.NioServerBoss.run(NioServerBoss.java:42)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

首先检查了微服务中各个service的版本号,发现没什么问题。

很奇怪的是,这两个微服务单独启动的时候,却没有报错,想一想就应该知道是因为启动端口重复了。在server层的resources文件夹下面的dubbo.properties里面,将启动端口号修改成不一样的就好了。

这里写图片描述

dubbo.protocol.port=20860
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值