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

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u013086062/article/details/78776304

问题:

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

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

猜你喜欢

转载自blog.csdn.net/u013086062/article/details/78776304
今日推荐