org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss

使用dubbo+zookeeper项目时,出现的错误信息:

org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss

总结:
1.关掉防火墙:https://www.jianshu.com/p/e408a8489d75
2.dubbo的版本问题:
主要针对,dubbo-apache版本的。

# zookeeper 版本为3.4.17
# dubbo版本为4.0.2
# 据官方文档说,zookeeper-3.4版本的,适配apache-dubbo-4.0.1的比较好
# 但是我采用这种方法,问题还是存在
# 不推荐这种方法,希望大家指出问题。

            <dependency>
             <groupId>org.apache.dubbogroupId>
             <artifactId>dubbo-spring-boot-starterartifactId>
             <version>2.7.5version>
         dependency>
         <dependency>
             <groupId>org.apache.curatorgroupId>
             <artifactId>curator-frameworkartifactId>
             <version>4.0.1version>
         dependency>
         <dependency>
             <groupId>org.apache.curatorgroupId>
             <artifactId>curator-recipesartifactId>
             <version>4.0.1version>
         dependency>

3.zookeeper设置超时调大一点:https://blog.csdn.net/qq_43401720/article/details/99848905
4.我自己的,舍弃apache的,使用低版本的阿里版的(推荐!)。dubbo。
我亲自试过,可以连接目前的高版本zookeeper-3.5.7

# zookeeper是3.5.7高版本。
# 下面是我的dubbo配置:
		    <properties>
		        <java.version>1.8java.version>
		        <dubbo.version>2.6.5dubbo.version>
		    properties>

            
            <dependency>
                <groupId>com.alibaba.bootgroupId>
                <artifactId>dubbo-spring-boot-starterartifactId>
                <version> 0.2.1.RELEASEversion>
            dependency>
            <dependency>
                <groupId>com.alibabagroupId>
                <artifactId>dubboartifactId>
                <version> ${dubbo.version}version>
            dependency>
            <dependency>
                <groupId>io.nettygroupId>
                <artifactId>netty-allartifactId>
            dependency>

问题解决:

"C:\Program Files\Java\jdk1.8.0_181\bin\java.exe" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:D:\sorfware\IntelliJ  IDEA\IntelliJ IDEA 2018.3.5\lib\idea_rt.jar=49884:D:\sorfware\IntelliJ  IDEA\IntelliJ IDEA 2018.3.5\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_181\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\rt.jar;D:\workspace\IdeaWork20200415\dubbo_parent\provider\target\classes;D:\workspace\IdeaWork20200415\dubbo_parent\mapper\target\classes;D:\workspace\MAVENDATA\Repository\org\springframework\boot\spring-boot-starter-jdbc\2.1.10.RELEASE\spring-boot-starter-jdbc-2.1.10.RELEASE.jar;D:\workspace\MAVENDATA\Repository\com\zaxxer\HikariCP\3.2.0\HikariCP-3.2.0.jar;D:\workspace\MAVENDATA\Repository\org\springframework\spring-jdbc\5.1.11.RELEASE\spring-jdbc-5.1.11.RELEASE.jar;D:\workspace\MAVENDATA\Repository\org\springframework\spring-beans\5.1.11.RELEASE\spring-beans-5.1.11.RELEASE.jar;D:\workspace\MAVENDATA\Repository\org\springframework\spring-tx\5.1.11.RELEASE\spring-tx-5.1.11.RELEASE.jar;D:\workspace\MAVENDATA\Repository\org\mybatis\spring\boot\mybatis-spring-boot-starter\2.1.1\mybatis-spring-boot-starter-2.1.1.jar;D:\workspace\MAVENDATA\Repository\org\mybatis\spring\boot\mybatis-spring-boot-autoconfigure\2.1.1\mybatis-spring-boot-autoconfigure-2.1.1.jar;D:\workspace\MAVENDATA\Repository\org\mybatis\mybatis\3.5.3\mybatis-3.5.3.jar;D:\workspace\MAVENDATA\Repository\org\mybatis\mybatis-spring\2.0.3\mybatis-spring-2.0.3.jar;D:\workspace\MAVENDATA\Repository\mysql\mysql-connector-java\5.1.48\mysql-connector-java-5.1.48.jar;D:\workspace\IdeaWork20200415\dubbo_parent\pojo\target\classes;D:\workspace\IdeaWork20200415\dubbo_parent\api\target\classes;D:\workspace\MAVENDATA\Repository\org\apache\curator\curator-recipes\4.2.0\curator-recipes-4.2.0.jar;D:\workspace\MAVENDATA\Repository\org\apache\curator\curator-framework\4.2.0\curator-framework-4.2.0.jar;D:\workspace\MAVENDATA\Repository\org\apache\curator\curator-client\4.2.0\curator-client-4.2.0.jar;D:\workspace\MAVENDATA\Repository\org\apache\zookeeper\zookeeper\3.5.4-beta\zookeeper-3.5.4-beta.jar;D:\workspace\MAVENDATA\Repository\commons-cli\commons-cli\1.2\commons-cli-1.2.jar;D:\workspace\MAVENDATA\Repository\log4j\log4j\1.2.17\log4j-1.2.17.jar;D:\workspace\MAVENDATA\Repository\org\apache\yetus\audience-annotations\0.5.0\audience-annotations-0.5.0.jar;D:\workspace\MAVENDATA\Repository\io\netty\netty\3.10.6.Final\netty-3.10.6.Final.jar;D:\workspace\MAVENDATA\Repository\com\google\guava\guava\27.0.1-jre\guava-27.0.1-jre.jar;D:\workspace\MAVENDATA\Repository\com\google\guava\failureaccess\1.0.1\failureaccess-1.0.1.jar;D:\workspace\MAVENDATA\Repository\com\google\guava\listenablefuture\9999.0-empty-to-avoid-conflict-with-guava\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;D:\workspace\MAVENDATA\Repository\com\google\code\findbugs\jsr305\3.0.2\jsr305-3.0.2.jar;D:\workspace\MAVENDATA\Repository\org\checkerframework\checker-qual\2.5.2\checker-qual-2.5.2.jar;D:\workspace\MAVENDATA\Repository\com\google\errorprone\error_prone_annotations\2.2.0\error_prone_annotations-2.2.0.jar;D:\workspace\MAVENDATA\Repository\com\google\j2objc\j2objc-annotations\1.1\j2objc-annotations-1.1.jar;D:\workspace\MAVENDATA\Repository\org\codehaus\mojo\animal-sniffer-annotations\1.17\animal-sniffer-annotations-1.17.jar;D:\workspace\MAVENDATA\Repository\org\slf4j\slf4j-api\1.7.29\slf4j-api-1.7.29.jar;D:\workspace\MAVENDATA\Repository\org\springframework\boot\spring-boot-starter\2.1.10.RELEASE\spring-boot-starter-2.1.10.RELEASE.jar;D:\workspace\MAVENDATA\Repository\org\springframework\boot\spring-boot\2.1.10.RELEASE\spring-boot-2.1.10.RELEASE.jar;D:\workspace\MAVENDATA\Repository\org\springframework\spring-context\5.1.11.RELEASE\spring-context-5.1.11.RELEASE.jar;D:\workspace\MAVENDATA\Repository\org\springframework\spring-aop\5.1.11.RELEASE\spring-aop-5.1.11.RELEASE.jar;D:\workspace\MAVENDATA\Repository\org\springframework\spring-expression\5.1.11.RELEASE\spring-expression-5.1.11.RELEASE.jar;D:\workspace\MAVENDATA\Repository\org\springframework\boot\spring-boot-autoconfigure\2.1.10.RELEASE\spring-boot-autoconfigure-2.1.10.RELEASE.jar;D:\workspace\MAVENDATA\Repository\org\springframework\boot\spring-boot-starter-logging\2.1.10.RELEASE\spring-boot-starter-logging-2.1.10.RELEASE.jar;D:\workspace\MAVENDATA\Repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;D:\workspace\MAVENDATA\Repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;D:\workspace\MAVENDATA\Repository\org\apache\logging\log4j\log4j-to-slf4j\2.11.2\log4j-to-slf4j-2.11.2.jar;D:\workspace\MAVENDATA\Repository\org\apache\logging\log4j\log4j-api\2.11.2\log4j-api-2.11.2.jar;D:\workspace\MAVENDATA\Repository\org\slf4j\jul-to-slf4j\1.7.29\jul-to-slf4j-1.7.29.jar;D:\workspace\MAVENDATA\Repository\javax\annotation\javax.annotation-api\1.3.2\javax.annotation-api-1.3.2.jar;D:\workspace\MAVENDATA\Repository\org\springframework\spring-core\5.1.11.RELEASE\spring-core-5.1.11.RELEASE.jar;D:\workspace\MAVENDATA\Repository\org\springframework\spring-jcl\5.1.11.RELEASE\spring-jcl-5.1.11.RELEASE.jar;D:\workspace\MAVENDATA\Repository\org\yaml\snakeyaml\1.23\snakeyaml-1.23.jar;D:\workspace\MAVENDATA\Repository\org\springframework\boot\spring-boot-devtools\2.1.10.RELEASE\spring-boot-devtools-2.1.10.RELEASE.jar" com.sxt.ProviderApplication

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::       (v2.1.10.RELEASE)

2020-05-01 19:06:34.810  INFO 5780 --- [  restartedMain] com.sxt.ProviderApplication              : Starting ProviderApplication on my-notebook with PID 5780 (D:\workspace\IdeaWork20200415\dubbo_parent\provider\target\classes started by My in D:\workspace\IdeaWork20200415\dubbo_parent)
2020-05-01 19:06:34.822  INFO 5780 --- [  restartedMain] com.sxt.ProviderApplication              : The following profiles are active: mybatis
2020-05-01 19:06:35.037  INFO 5780 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2020-05-01 19:06:39.501  INFO 5780 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2020-05-01 19:06:39.640  INFO 5780 --- [  restartedMain] com.sxt.ProviderApplication              : Started ProviderApplication in 6.747 seconds (JVM running for 10.232)

Process finished with exit code 0

你可能感兴趣的:(dubbo)