解决dubbo错误ip及ip乱入问题的方法
程序员文章站
2023-12-21 12:41:16
问题
在本地启动dubbo时,服务注册在本地的zookeeper ,但是注册ip却不是本地的ip。产生问题,导致consumer 找不到provider ,访问不了服务。...
问题
在本地启动dubbo时,服务注册在本地的zookeeper ,但是注册ip却不是本地的ip。产生问题,导致consumer 找不到provider ,访问不了服务。
- 例如 本地ip为 10.0.0.1 ,但是zookeeper上的注册ip 可能是 196.168.0.1
产生原因,随机产生,可能是你重启一下机器,或者电脑小智一段时间就会发生。
- 报错类似
com.alibaba.dubbo.remoting.remotingexception: client(url: dubbo://100.106.199.34:20880/con.xxxx.xxxx.xxxx.xxxx.nginxlogservice?accesslog=./logs/xxxx-xxxx-provider-dubbo.log&anyhost=true&application=xxxx-xxxx&check=false&codec=dubbo&default.accesslog=true&default.check=false&default.delay=-1&default.loadbalance=roundrobin&default.retries=0&default.timeout=60000&delay=-1&dubbo=2.8.4&generic=false&heartbeat=60000&interface=cn.xxxx.xxxx.xxxx.xxxx.nginxlogservice&logger=slf4j&methods=getmodelpage&organization=xxxx&owner=xxxx&pid=38690&side=consumer×tamp=1545988767460) failed to connect to server /100.106.199.34:20880 client-side timeout 3000ms (elapsed: 3004ms) from netty client 100.106.199.34 using dubbo version 2.8.4 at com.alibaba.dubbo.remoting.transport.netty.nettyclient.doconnect(nettyclient.java:147) at com.alibaba.dubbo.remoting.transport.abstractclient.connect(abstractclient.java:280) at com.alibaba.dubbo.remoting.transport.abstractclient$1.run(abstractclient.java:145) at java.util.concurrent.executors$runnableadapter.call(executors.java:511) at java.util.concurrent.futuretask.runandreset(futuretask.java:308) at java.util.concurrent.scheduledthreadpoolexecutor$scheduledfuturetask.access$301(scheduledthreadpoolexecutor.java:180) at java.util.concurrent.scheduledthreadpoolexecutor$scheduledfuturetask.run(scheduledthreadpoolexecutor.java:294) at java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1142) at java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:617) at java.lang.thread.run(thread.java:745)
caused by: org.springframework.remoting.remoteconnectfailureexception: could not connect to remote service [rmi://192.168.72.235:20881/com.ztesoft.zsmartcity.ynzw.demo.service.demoservice]; nested exception is java.rmi.connectexception: connection refused to host: 127.0.0.1; nested exception is:
caused by: java.lang.illegalstateexception: failed to check the status of the service com.xxx.xxx.service.loginservice. no provider available for the service com.xxxx.xxxx.service.loginservice:3.0 from the url zookeeper://202.106.199.37:2181/com.alibaba.dubbo.registry.registryservice?anyhost=true&application=xxx&application.version=3.0&check=false&default.timeout=5000&dubbo=2.5.3&interface=com.xxx.xxx.service.loginservice&methods=alogin,bpassword,userlogin,modifypasswordlogin,validate,fversion,xlogout,userlogout,gettest,getcode,alogin,atoken,auser&pid=2200&revision=1.0&side=consumer×tamp=1462534379328&version=3.0 to the consumer 202.106.199.37 use dubbo version 2.5.3
解决方法
在程序配置文件中 配置dubbo 的注册中心“dubbo.registry.address
” 时要注意不要配置127.0.0.1 要配置为 localhost。
然后在配置本地的/etc/hosts 文件中
127.0.0.1 localhost
问题原因
怀疑原因:为本地配置127.0.0.1 时由于连着网络所以dns 解析解析到了你的网络上了。么有解析到本机造成的。但是并不确定是不是这个原因。
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对的支持。如果你想了解更多相关内容请查看下面相关链接