您的位置:首页 > 大数据 > 人工智能

dubbo实战---No provider available for the service

2017-12-11 20:53 901 查看
问题:
  java.lang.IllegalStateException:Failed to check the status of the servicecom.alibaba.dubbo.demo.consumer.HelloService. No provider available for the service com.alibaba.dubbo.demo.consumer.HelloService
from the urlzookeeper://*.*.*.*:2181/com.alibaba.dubbo.registry.RegistryService?anyhost=true&application=customer-center-consumer-app&check=false&dubbo=2.5.5&interface=com.alibaba.dubbo.demo.consumer.HelloService&methods=register,sayHello&pid=22130&revision=2.5.5&side=consumer&timestamp=1507604148514to
the consumer 0.0.0.111 use dubbo version 2.5.5


    No provider available for the service 遇到这个问题想到的解决方法是provider没有注册到注册中心上,导致consumer没有拿到服务.但是在dubbo-admin上看到了provider在提供者列表上显示着,只是感觉provider注册到注册中心的地址不对.

于是写了如下代码,发布成了一个服务.

 public static void main(String[] args) {
InetAddress localAddress = NetUtils.getLocalAddress();
System.out.println(localAddress.getHostAddress());
}

发布以后返回的ip地址是0.0.0.111.得出provider注册到注册中心的ip地址是不对的.


原因:
dubbo服务发布的服务器的IP使用的是DHCP,而不是静态的,dubbo服务provider注册的地址为0.0.0.111,而consumer去找的地址为192.168.22.111,所以造成了consumer找不到provider的结果.

解决方法:
将服务器IP获取方式改为静态的即可.
在网上也找过很多的解决方法,但是没有一个是合适的,还是要对症下药.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐