dubbo multicast 連線失敗解決方案
阿新 • • 發佈:2018-11-04
一、異常資訊
Exception in thread "main" com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method sayHello in the service com.demo.service.DemoService. No provider available for the service com.demo.service.DemoService:1.0 from registry 224.5.6.7:1234 on the consumer 10.10.10.1 using the dubbo version 2.5.3. Please check if the providers have been started and registered.
Exception in thread "main" com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method sayHello in the service com.demo.service.DemoService. No provider available for the service com.demo.service.DemoService:1.0 from registry 224.5.6.7:1234 on the consumer 10.10.10.1 using the dubbo version 2.5.3. Please check if the providers have been started and registered. at com.alibaba.dubbo.rpc.cluster.support.AbstractClusterInvoker.checkInvokers(AbstractClusterInvoker.java:246) at com.alibaba.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:55) at com.alibaba.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:227) at com.alibaba.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:72) at com.alibaba.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:52) at com.alibaba.dubbo.common.bytecode.proxy0.sayHello(proxy0.java) at com.demo.consumer.Consumer.main(Consumer.java:21)
二、異常原因以及解決方案
原因一:使用端和廣播端的xxxService類名以及路徑不匹配
<!-- 廣播端:xxxService 以及 version 必須與使用端一致--> <dubbo:service interface="com.demo.service.DemoService" ref="demoService" version="1.0"/> <!-- 使用端:xxxService 以及 version 必須與廣播端一致--> <dubbo:reference id="demoService" check="false" interface="com.demo.service.DemoService" version="1.0"/>
原因二:使用端和廣播端的廣播地址不匹配
<!-- 廣播端:使用 multicast 廣播註冊中心暴露服務地址 (224.0.0.0 - 239.255.255.255) -->
<dubbo:registry address="multicast://224.5.6.7:1234?unicast=false"/>
<!-- 使用端:配置服務註冊中心,必須有廣播端一致 -->
<dubbo:registry address="multicast://224.5.6.7:1234?unicast=false"/>
原因三:該地址在網路中已被佔用;改用其他地址(224.0.0.0-239.255.255.255之間)
注:如果還不好用,可以直接改成直連
<!-- 廣播端:直連模式 -->
<dubbo:registry address="N/A"/>
<!-- 使用端:直連模式 在 dubbo:reference中 加上url="dubbo://127.0.0.1:20880" -->
<dubbo:reference id="demoService" check="false" interface="com.demo.service.DemoService" version="1.0" url="dubbo://127.0.0.1:20880"/>