解决阿里云部署dubbo+zookeeper和生产者时使用内网IP的问题

问题复现

zookeeper放置在阿里云服务器A,生产者放置在阿里云服务器B,消费者放置在本地的idea里面,启动消费者时出现问题:找不到生产者
在这里插入图片描述
具体内容为:

com.alibaba.dubbo.remoting.RemotingException: client(url: dubbo://172.17.244.206:20886/com.books.service.VipService?anyhost=true&application=springboot-dubbo-anno-consumer&check=false&codec=dubbo&default.retries=0&default.timeout=5000&dubbo=2.6.2&generic=false&heartbeat=60000&interface=com.books.service.VipService&methods=selectAllVip,selectAllVipManage,selectAllVipManageByScreen,updateUser_status,selectAllVipManageCount,selectUserXinxi,deleteVipLevel,addVipLevel,selectVipLevelByVip_no,selectVipUserIntegralByScreen,editVipLevel,selectVipUserIntegral,selectAllVipManageByScreenCount,selectVipUserIntegralByScreenCount,selectVipUserIntegralCount,editIntegralByUser_no,viewIntegralByUser_no&pid=10772&qos.accept.foreign.ip=false&qos.enable=true&qos.port=33333&register.ip=172.16.6.11&remote.timestamp=1594469993720&revision=1.0.0&side=consumer&timestamp=1594613447230) failed to connect to server /172.17.244.206:20886 client-side timeout 3000ms (elapsed: 3001ms) from netty client 172.16.6.11 using dubbo version 2.6.2

分析原因

发现关键一句:failed to connect to server /172.17.244.206:20886
说明连接不到生产者,这里看到在注册中心的生产者IP明显是一个阿里云的内网地址
在这里插入图片描述
所以才会导致在本地无法连接到生产者。

解决办法

将阿里云的本机IP改为对应的公网IP即可
1.先查看本机hostname
在这里插入图片描述
2.修改hosts
在这里插入图片描述
在这里插入图片描述
修改后立即生效
3.重启生产者和消费者
4.查看注册中心,已经改为公网ip,问题解决
在这里插入图片描述
参考文章:
https://blog.youkuaiyun.com/xlgen157387/article/details/52702659

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值