问题复现
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®ister.ip=172.16.6.11&remote.timestamp=1594469993720&revision=1.0.0&side=consumer×tamp=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