辛星dubbo答疑第三篇:Failed to subscribe consumer

在我们使用zookeeper作为服务发现时,可能会出现如下的错误:

信息:  [DUBBO] Reconnect to registry dubbo://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=demo-provider&callbacks=10000&connect.timeout=10000&dubbo=2.0.2&interface=com.alibaba.dubbo.registry.RegistryService&lazy=true&methods=lookup,subscribe,unsubscribe,unregister,register&pid=98092&reconnect=false&sticky=true&subscribe.1.callback=true&timeout=10000×tamp=1543760171168&unsubscribe.1.callback=false, dubbo version: 2.6.5, current host: 192.168.1.105
Dec 02, 2018 10:16:47 PM com.alibaba.dubbo.registry.dubbo.DubboRegistry info
信息:  [DUBBO] Recover subscribe url [consumer://192.168.1.105/com.alibaba.dubbo.registry.RegistryService?application=demo-provider&callbacks=10000&connect.timeout=10000&dubbo=2.0.2&interface=com.alibaba.dubbo.registry.RegistryService&lazy=true&methods=lookup,subscribe,unsubscribe,unregister,register&pid=98092&reconnect=false&sticky=true&subscribe.1.callback=true&timeout=10000×tamp=1543760171168&unsubscribe.1.callback=false], dubbo version: 2.6.5, current host: 192.168.1.105
Dec 02, 2018 10:16:50 PM com.alibaba.dubbo.registry.dubbo.DubboRegistry info
信息:  [DUBBO] Reconnect to registry dubbo://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=demo-provider&callbacks=10000&connect.timeout=10000&dubbo=2.0.2&interface=com.alibaba.dubbo.registry.RegistryService&lazy=true&methods=lookup,subscribe,unsubscribe,unregister,register&pid=98092&reconnect=false&sticky=true&subscribe.1.callback=true&timeout=10000×tamp=1543760171168&unsubscribe.1.callback=false, dubbo version: 2.6.5, current host: 192.168.1.105
Dec 02, 2018 10:16:50 PM com.alibaba.dubbo.registry.dubbo.DubboRegistry info
信息:  [DUBBO] Recover subscribe url [consumer://192.168.1.105/com.alibaba.dubbo.registry.RegistryService?application=demo-provider&callbacks=10000&connect.timeout=10000&dubbo=2.0.2&interface=com.alibaba.dubbo.registry.RegistryService&lazy=true&methods=lookup,subscribe,unsubscribe,unregister,register&pid=98092&reconnect=false&sticky=true&subscribe.1.callback=true&timeout=10000×tamp=1543760171168&unsubscribe.1.callback=false], dubbo version: 2.6.5, current host: 192.168.1.105
Dec 02, 2018 10:16:51 PM com.alibaba.dubbo.remoting.transport.netty.NettyClient info
信息:  [DUBBO] Close old netty channel [id: 0x4bff7da0, /192.168.1.105:52256 :> /192.168.1.105:2181] on create new netty channel [id: 0x05496eca, /192.168.1.105:52277 => /192.168.1.105:2181], dubbo version: 2.6.5, current host: 192.168.1.105
Dec 02, 2018 10:16:51 PM com.alibaba.dubbo.remoting.transport.AbstractClient info
信息:  [DUBBO] Successed connect to server /192.168.1.105:2181 from NettyClient 192.168.1.105 using dubbo version 2.6.5, channel is NettyChannel [channel=[id: 0x05496eca, /192.168.1.105:52277 => /192.168.1.105:2181]], dubbo version: 2.6.5, current host: 192.168.1.105
Dec 02, 2018 10:16:51 PM com.alibaba.dubbo.rpc.protocol.dubbo.CallbackServiceCodec info
信息:  [DUBBO] export a callback service :dubbo://192.168.1.105:52277/com.alibaba.dubbo.registry.NotifyListener.20224131?application=demo-provider&callbacks=10000&check=false&connect.timeout=10000&dubbo=2.0.2&interface=com.alibaba.dubbo.registry.NotifyListener&is_callback_service=true&isserver=false&lazy=true&methods=notify&pid=98092&reconnect=false&remote.timestamp=1543760171168&sticky=true&subscribe.1.callback=true&timeout=10000×tamp=1543760171168&unsubscribe.1.callback=false, on NettyChannel [channel=[id: 0x05496eca, /192.168.1.105:52277 => /192.168.1.105:2181]], url is: dubbo://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=demo-provider&callbacks=10000&check=false&connect.timeout=10000&dubbo=2.0.2&interface=com.alibaba.dubbo.registry.RegistryService&lazy=true&methods=lookup,subscribe,unsubscribe,unregister,register&pid=98092&reconnect=false&remote.timestamp=1543760171168&sticky=true&subscribe.1.callback=true&timeout=10000×tamp=1543760171168&unsubscribe.1.callback=false, dubbo version: 2.6.5, current host: 192.168.1.105
Dec 02, 2018 10:16:51 PM com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol info
信息:  [DUBBO] disconnected from /192.168.1.105:2181,url:dubbo://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=demo-provider&callbacks=10000&check=false&codec=dubbo&connect.timeout=10000&dubbo=2.0.2&heartbeat=60000&interface=com.alibaba.dubbo.registry.RegistryService&lazy=true&methods=lookup,subscribe,unsubscribe,unregister,register&pid=98092&reconnect=false&remote.timestamp=1543760171168&send.reconnect=true&sticky=true&subscribe.1.callback=true&timeout=10000×tamp=1543760171168&unsubscribe.1.callback=false, dubbo version: 2.6.5, current host: 192.168.1.105
Dec 02, 2018 10:16:53 PM com.alibaba.dubbo.registry.dubbo.DubboRegistry info
信息:  [DUBBO] Reconnect to registry dubbo://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=demo-provider&callbacks=10000&connect.timeout=10000&dubbo=2.0.2&interface=com.alibaba.dubbo.registry.RegistryService&lazy=true&methods=lookup,subscribe,unsubscribe,unregister,register&pid=98092&reconnect=false&sticky=true&subscribe.1.callback=true&timeout=10000×tamp=1543760171168&unsubscribe.1.callback=false, dubbo version: 2.6.5, current host: 192.168.1.105
Dec 02, 2018 10:16:53 PM com.alibaba.dubbo.registry.dubbo.DubboRegistry info
信息:  [DUBBO] Recover subscribe url [consumer://192.168.1.105/com.alibaba.dubbo.registry.RegistryService?application=demo-provider&callbacks=10000&connect.timeout=10000&dubbo=2.0.2&interface=com.alibaba.dubbo.registry.RegistryService&lazy=true&methods=lookup,subscribe,unsubscribe,unregister,register&pid=98092&reconnect=false&sticky=true&subscribe.1.callback=true&timeout=10000×tamp=1543760171168&unsubscribe.1.callback=false], dubbo version: 2.6.5, current host: 192.168.1.105
Dec 02, 2018 10:16:56 PM com.alibaba.dubbo.registry.dubbo.DubboRegistry info
信息:  [DUBBO] Reconnect to registry dubbo://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=demo-provider&callbacks=10000&connect.timeout=10000&dubbo=2.0.2&interface=com.alibaba.dubbo.registry.RegistryService&lazy=true&methods=lookup,subscribe,unsubscribe,unregister,register&pid=98092&reconnect=false&sticky=true&subscribe.1.callback=true&timeout=10000×tamp=1543760171168&unsubscribe.1.callback=false, dubbo version: 2.6.5, current host: 192.168.1.105
Dec 02, 2018 10:16:56 PM com.alibaba.dubbo.registry.dubbo.DubboRegistry info
信息:  [DUBBO] Recover subscribe url [consumer://192.168.1.105/com.alibaba.dubbo.registry.RegistryService?application=demo-provider&callbacks=10000&connect.timeout=10000&dubbo=2.0.2&interface=com.alibaba.dubbo.registry.RegistryService&lazy=true&methods=lookup,subscribe,unsubscribe,unregister,register&pid=98092&reconnect=false&sticky=true&subscribe.1.callback=true&timeout=10000×tamp=1543760171168&unsubscribe.1.callback=false], dubbo version: 2.6.5, current host: 192.168.1.105
Exception in thread "main" java.lang.IllegalStateException: Failed to subscribe consumer://192.168.1.105/com.alibaba.dubbo.registry.RegistryService?application=demo-provider&callbacks=10000&connect.timeout=10000&dubbo=2.0.2&interface=com.alibaba.dubbo.registry.RegistryService&lazy=true&methods=lookup,subscribe,unsubscribe,unregister,register&pid=98092&reconnect=false&sticky=true&subscribe.1.callback=true&timeout=10000×tamp=1543760171168&unsubscribe.1.callback=false, cause: Failed to invoke the method subscribe in the service com.alibaba.dubbo.registry.RegistryService. Tried 3 times of the providers [127.0.0.1:2181] (1/1) from the registry 127.0.0.1:2181 on the consumer 192.168.1.105 using the dubbo version 2.6.5. Last error is: Invoke remote method timeout. method: subscribe, provider: dubbo://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=demo-provider&callbacks=10000&check=false&connect.timeout=10000&dubbo=2.0.2&interface=com.alibaba.dubbo.registry.RegistryService&lazy=true&methods=lookup,subscribe,unsubscribe,unregister,register&pid=98092&reconnect=false&remote.timestamp=1543760171168&sticky=true&subscribe.1.callback=true&timeout=10000×tamp=1543760171168&unsubscribe.1.callback=false, cause: Waiting server-side response timeout. start time: 2018-12-02 22:16:46.643, end time: 2018-12-02 22:16:56.647, client elapsed: 3 ms, server elapsed: 10001 ms, timeout: 10000 ms, request: Request [id=4, version=2.0.2, 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://192.168.1.105/com.alibaba.dubbo.registry.RegistryService?application=demo-provider&callbacks=10000&connect.timeout=10000&dubbo=2.0.2&interface=com.alibaba.dubbo.registry.RegistryService&lazy=true&methods=lookup,subscribe,unsubscribe,unregister,register&pid=98092&reconnect=false&sticky=true&subscribe.1.callback=true&timeout=10000×tamp=1543760171168&unsubscribe.1.callback=false, com.alibaba.dubbo.registry.integration.RegistryDirectory@1349883], attachments={path=com.alibaba.dubbo.registry.RegistryService, sys_callback_arg-1=20224131, interface=com.alibaba.dubbo.registry.RegistryService, version=0.0.0, timeout=10000}]], channel: 192.168.1.105:0 -> /127.0.0.1:2181
	at com.alibaba.dubbo.registry.support.FailbackRegistry.subscribe(FailbackRegistry.java:213)
	at com.alibaba.dubbo.registry.integration.RegistryDirectory.subscribe(RegistryDirectory.java:159)
	at com.alibaba.dubbo.registry.dubbo.DubboRegistryFactory.createRegistry(DubboRegistryFactory.java:97)
	at com.alibaba.dubbo.registry.support.AbstractRegistryFactory.getRegistry(AbstractRegistryFactory.java:96)
	at com.alibaba.dubbo.registry.RegistryFactory$Adaptive.getRegistry(RegistryFactory$Adaptive.java)
	at com.alibaba.dubbo.registry.integration.RegistryProtocol.getRegistry(RegistryProtocol.java:203)
	at com.alibaba.dubbo.registry.integration.RegistryProtocol.export(RegistryProtocol.java:137)
	at com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:55)
	at com.alibaba.dubbo.qos.protocol.QosProtocolWrapper.export(QosProtocolWrapper.java:60)
	at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:98)
	at com.alibaba.dubbo.rpc.Protocol$Adaptive.export(Protocol$Adaptive.java)
	at com.alibaba.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:513)
	at com.alibaba.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:358)
	at com.alibaba.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:317)
	at com.alibaba.dubbo.config.ServiceConfig.export(ServiceConfig.java:216)
	at com.alibaba.dubbo.config.spring.ServiceBean.export(ServiceBean.java:291)
	at com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:131)
	at com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:53)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347)
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
	at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
	at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:93)
	at com.mengzhidu.java.dubbo.user.Application.main(Application.java:16)
Caused by: com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method subscribe in the service com.alibaba.dubbo.registry.RegistryService. Tried 3 times of the providers [127.0.0.1:2181] (1/1) from the registry 127.0.0.1:2181 on the consumer 192.168.1.105 using the dubbo version 2.6.5. Last error is: Invoke remote method timeout. method: subscribe, provider: dubbo://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=demo-provider&callbacks=10000&check=false&connect.timeout=10000&dubbo=2.0.2&interface=com.alibaba.dubbo.registry.RegistryService&lazy=true&methods=lookup,subscribe,unsubscribe,unregister,register&pid=98092&reconnect=false&remote.timestamp=1543760171168&sticky=true&subscribe.1.callback=true&timeout=10000×tamp=1543760171168&unsubscribe.1.callback=false, cause: Waiting server-side response timeout. start time: 2018-12-02 22:16:46.643, end time: 2018-12-02 22:16:56.647, client elapsed: 3 ms, server elapsed: 10001 ms, timeout: 10000 ms, request: Request [id=4, version=2.0.2, 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://192.168.1.105/com.alibaba.dubbo.registry.RegistryService?application=demo-provider&callbacks=10000&connect.timeout=10000&dubbo=2.0.2&interface=com.alibaba.dubbo.registry.RegistryService&lazy=true&methods=lookup,subscribe,unsubscribe,unregister,register&pid=98092&reconnect=false&sticky=true&subscribe.1.callback=true&timeout=10000×tamp=1543760171168&unsubscribe.1.callback=false, com.alibaba.dubbo.registry.integration.RegistryDirectory@1349883], attachments={path=com.alibaba.dubbo.registry.RegistryService, sys_callback_arg-1=20224131, interface=com.alibaba.dubbo.registry.RegistryService, version=0.0.0, timeout=10000}]], channel: 192.168.1.105:0 -> /127.0.0.1:2181
	at com.alibaba.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:109)
	at com.alibaba.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:244)
	at com.alibaba.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:75)
	at com.alibaba.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:52)
	at com.alibaba.dubbo.common.bytecode.proxy0.subscribe(proxy0.java)
	at com.alibaba.dubbo.registry.dubbo.DubboRegistry.doSubscribe(DubboRegistry.java:151)
	at com.alibaba.dubbo.registry.support.FailbackRegistry.subscribe(FailbackRegistry.java:196)
	... 27 more
Caused by: com.alibaba.dubbo.remoting.TimeoutException: Waiting server-side response timeout. start time: 2018-12-02 22:16:46.643, end time: 2018-12-02 22:16:56.647, client elapsed: 3 ms, server elapsed: 10001 ms, timeout: 10000 ms, request: Request [id=4, version=2.0.2, 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://192.168.1.105/com.alibaba.dubbo.registry.RegistryService?application=demo-provider&callbacks=10000&connect.timeout=10000&dubbo=2.0.2&interface=com.alibaba.dubbo.registry.RegistryService&lazy=true&methods=lookup,subscribe,unsubscribe,unregister,register&pid=98092&reconnect=false&sticky=true&subscribe.1.callback=true&timeout=10000×tamp=1543760171168&unsubscribe.1.callback=false, com.alibaba.dubbo.registry.integration.RegistryDirectory@1349883], attachments={path=com.alibaba.dubbo.registry.RegistryService, sys_callback_arg-1=20224131, interface=com.alibaba.dubbo.registry.RegistryService, version=0.0.0, timeout=10000}]], channel: 192.168.1.105:0 -> /127.0.0.1:2181
	at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.get(DefaultFuture.java:159)
	at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.get(DefaultFuture.java:135)
	at com.alibaba.dubbo.rpc.protocol.dubbo.DubboInvoker.doInvoke(DubboInvoker.java:95)
	at com.alibaba.dubbo.rpc.protocol.AbstractInvoker.invoke(AbstractInvoker.java:155)
	at com.alibaba.dubbo.rpc.listener.ListenerInvokerWrapper.invoke(ListenerInvokerWrapper.java:77)
	at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:75)
	at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)
	at com.alibaba.dubbo.rpc.protocol.dubbo.filter.FutureFilter.invoke(FutureFilter.java:54)
	at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)
	at com.alibaba.dubbo.rpc.filter.ConsumerContextFilter.invoke(ConsumerContextFilter.java:49)
	at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)
	at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:56)
	at com.alibaba.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:78)
	... 33 more
Dec 02, 2018 10:16:56 PM com.alibaba.dubbo.config.DubboShutdownHook info
信息:  [DUBBO] Run shutdown hook now., dubbo version: 2.6.5, current host: 192.168.1.105

类似上面这种错误,通常是dubbo的register的地址没有配置正确,比如下面给一个错误的范例:


这里是因为我们没有配置协议,它会默认认为是dubbo协议,所以地址为当做dubbo://127.0.0.1:2181,这里我们想让它当做zookeeper的话,只要我们在地址前面加上 zookeeper:// 即可,比如我们修改成如下配置:


这样,我们就不会发现它就会正常的实现服务的注册了。

你可能感兴趣的:(微服务框架-dubbo,java,辛星,dubbo,答疑,教程)