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

来源:互联网 发布:ise12.3软件下载 编辑:程序博客网 时间:2024/06/14 08:30

问题:

  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获取方式改为静态的即可.

在网上也找过很多的解决方法,但是没有一个是合适的,还是要对症下药.

阅读全文
1 0
原创粉丝点击