报错: org.apache.zookeeper.ClientCnxn$EndOfStreamException: Unable to read additional data from server sessionid 0x108e8afac8f0077, likely server has closed socket
报错: org.apache.zookeeper.KeeperException$OperationTimeoutException: KeeperErrorCode = OperationTimeout
提示: SASL config status: Will not attempt to authenticate using SASL (unknown error)
原因: zookeeper默认使用了ZooKeeperSaslClient,而这个过程中调用了getHostName方法,从而造成程序阻塞。
解决方式一: 可以通过在hosts文件添加上zookeeper的ip地址,使得getHostName可以直接使用hosts里面的dns结果。
解决方式二: 主动关闭ZooKeeperSaslClient,直接在SpringBoot启动类加System.setProperty(“zookeeper.sasl.client”, “false”); 例子如下
@SpringBootApplication
public class TestApplication {
public static void main(String[] args) {
System.setProperty("zookeeper.sasl.client", "false");
SpringApplication.run(TestApplication.class, args);
}
}
|