dubbo服务注册问题 调用服务超时

寵の児 提交于 2019-12-04 20:44:04

异常栈信息如下

Caused by: com.alibaba.dubbo.remoting.TimeoutException: Waiting server-side response timeout. start time: 2015-03-10 13:50:56.132, end time: 2015-03-10 13:51:06.139, client elapsed: 6 ms, server elapsed: 10001 ms, timeout: 10000 ms, request: Request [id=4, version=2.0.0, twoway=true, event=false, broken=false, data=RpcInvocation [methodName=subscribe, parameterTypes=[class com.alibaba.dubbo.common.URL, interface com.alibaba.dubbo.registry.NotifyListener], arguments=[consumer://10.0.30.38/com.alibaba.dubbo.registry.RegistryService?application=taxi-web&callbacks=10000&connect.timeout=10000&dubbo=2.5.3&interface=com.alibaba.dubbo.registry.RegistryService&lazy=true&methods=register,subscribe,unregister,unsubscribe,lookup&pid=20040&reconnect=false&sticky=true&subscribe.1.callback=true&timeout=10000&timestamp=1425966635807&unsubscribe.1.callback=false, com.alibaba.dubbo.registry.integration.RegistryDirectory@4b53aea8], attachments={sys_callback_arg-1=1263775400, path=com.alibaba.dubbo.registry.RegistryService, interface=com.alibaba.dubbo.registry.RegistryService, timeout=10000, version=0.0.0}]], channel: 10.0.30.38:0 -> /10.0.50.150:2181
at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.get(DefaultFuture.java:107)
at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.get(DefaultFuture.java:84)
at com.alibaba.dubbo.rpc.protocol.dubbo.DubboInvoker.doInvoke(DubboInvoker.java:96)
at com.alibaba.dubbo.rpc.protocol.AbstractInvoker.invoke(AbstractInvoker.java:144)
at com.alibaba.dubbo.rpc.protocol.dubbo.filter.FutureFilter.invoke(FutureFilter.java:53)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:75)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.filter.ConsumerContextFilter.invoke(ConsumerContextFilter.java:48)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.listener.ListenerInvokerWrapper.invoke(ListenerInvokerWrapper.java:74)
at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:53)
at com.alibaba.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:77)
… 85 more

看到这个错误不知道什么原因,注册中心用zookeeper, 最后发现properties文件里配置的注册中心地址一定是要带协议的,比如应该配置为:zookeeper://10.0.50.150:2181,而不是10.0.50.150:2181。

properties配置为10.0.50.150:2181会带来问题,因为没有配置注册中心协议,所以默认就是dubbo,这样这个地址其实变为了:dubbo://10.0.50.150:2181,dubbo会认为注册中心地址是一个dubbo服务,但其实10.0.50.150:2181运行的是一个zookeeper服务,根本不是dubbo服务,内部报错,然后注册时应用等待超时。

使用代码发布时 也一定要设置协议

       DUBBO_APPLICATION.setName(Config.getString("bdcsc2.explorer.application.name"));
       DUBBO_REGISTRY.setProtocol("zookeeper"); //注意该处
       DUBBO_REGISTRY.setAddress(ExConfig.ZK_CLUSTER_ADDRESS);

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!