SpringBoot integrates Dubbo + Zoopeer error

In the early years, the company has been using a set of microservices of Dubbo + Zookpeer, but a set of architecture is fully encapsulated, and the gameplay of this set of microservices has not been seriously explored. Later, I have been using SpringCloud or SpringCloudAlibaba in my work, so that I have forgotten how Dubbo’s microservices are played.

Recently, I started to explore this piece of knowledge, and built a set of SpringBoot integrated Dubbo + Zookpeer projects. Since my various middleware are all on the virtual machine, there is no service on Windows, which also leads to failure to start when the project is integrated.

After two days of investigation and Baidu, this problem was finally solved, here is a record.

The project configuration is as follows:

server.port=8081

dubbo.application.name=consumer
dubbo.protocol.name=dubbo
dubbo.protocol.port=20880

dubbo.registry.address=zookeeper://192.168.222.100:2181

During the startup process of the project, this message appears in the log all the time:

Default schema


Starting Initiating client connection, connectString=192.168.222.100:2181 sessionTimeout=60000 watcher=org.apache.curator.ConnectionState@4ed9f7b1

Socket connection established to 192.168.222.100/192.168.222.100:2181, initiating session


Session establishment complete on server 192.168.222.100/192.168.222.100:2181, sessionid = 0x100001f69fa000a, negotiated timeout = 40000

 The final error message is as follows:

java.lang.RuntimeException: Can not create registry service-discovery-registry://192.168.222.100:2181/org.apache.dubbo.registry.RegistryService?application=consumer&dubbo=2.0.2&interface=org.apache.dubbo.registry.

RegistryService&pid=15088&qos.enable=false&registry=zookeeper

&release=3.0.7&timeout=250000

The focus is on this bureau: Can not create registry service-discovery-registry

The translation is: Unable to create a service discovery registration registry .

 At first, I suspected that there was a problem with the Zookeeper installed by Docker. Later, I logged in to the ZooKeeper container to check the logs, and found the log of the successful startup of ZooKeeper: Welcome to ZooKeeper!

This shows that Zookpeer is fine, is there a problem with IP? Change the IP of the registration center address of the configuration file to localhost and report an error directly:

 Socket error occurred: localhost/0:0:0:0:0:0:0:1:2181: Connection refused: no further information


 Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)

。。。。。。

Application run failed

java.lang.IllegalStateException: java.lang.IllegalStateException: zookeeper not connected

This means that changing to localhost or 127.0.0.1 will not work.

After two days of investigation and Baidu, I found an article, and the author also solved this problem after hard work. We use the results of other people's labor, here is the source of the article:

When springboot integrates dubbo, it connects to zookeeper——Tiankeng

The author solved the problem by debugging the source code, and this article was also included in the Huawei Developer Alliance.

We also encountered the two problems that the author encountered.

In our case, the first one is because the IP we filled in the configuration file is wrong.

The second has not been resolved until we Baidu to this article.

After many attempts later, modifying the value of these two newly added parameters to 50 seconds, that is, 50000 is successful.

Finally, post the complete parameter configuration:

server.port=8081 

dubbo.application.name=consumer 
dubbo.protocol.name=dubbo 
dubbo.protocol.port=20880 

dubbo.registry.address=zookeeper://192.168.222.100:2181 
# Newly added parameter 
dubbo.registry. timeout=50000 
# Newly added parameter 
dubbo.registry.parameters.blockUntilConnectedWait=50

Guess you like

Origin blog.csdn.net/qq_42971035/article/details/129599758