gpt4 book ai didi

java - AuthenticationException : Invalid credentials! 在 Hazelcast 中使用正确的凭据时

转载 作者:行者123 更新时间:2023-12-02 01:20:31 35 4
gpt4 key购买 nike

所以我使用 Hazelcast 创建服务器和客户端。结果我在尝试运行客户端时遇到以下异常。

WARNING: hz.client_0 [56086-56015-56176] [3.7.8] Exception during initial connection to /192.168.1.112:5706
com.hazelcast.client.AuthenticationException: Invalid credentials!
at com.hazelcast.client.connection.nio.ClientConnectionManagerImpl$2.onResponse(ClientConnectionManagerImpl.java:530)
at com.hazelcast.client.connection.nio.ClientConnectionManagerImpl$2.onResponse(ClientConnectionManagerImpl.java:513)
at com.hazelcast.spi.impl.AbstractInvocationFuture$1.run(AbstractInvocationFuture.java:251)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
at com.hazelcast.util.executor.HazelcastManagedThread.executeRun(HazelcastManagedThread.java:76)
at com.hazelcast.util.executor.HazelcastManagedThread.run(HazelcastManagedThread.java:92)

错误来自:

ClientConfig hzConfig = getHzConfig();
hz = HazelcastClient.newHazelcastClient(hzConfig);

获取HzConfig:

private static ClientConfig getHzConfig() {
String addresses = Optional.ofNullable(System.getProperty("addresses")).orElseThrow(IllegalArgumentException::new);
String addressList[] = addresses.split(";");

ClientConfig clientConfig = new ClientConfig();
clientConfig.setGroupConfig(new GroupConfig("56086-56015-56176", "56086-56015-56176"));

ClientNetworkConfig networkConfig = clientConfig.getNetworkConfig();

for (String address : addressList) {
networkConfig.addAddress(address);
}

return clientConfig;
}

这是我的 hazelcast.xml

最佳答案

您的客户端配置使用密码“56086-56015-56176”,但您的成员配置包含组密码“56015-56086-56176”。 IE。第一部分和第二部分(破折号分隔)交换。

这是正确的客户端配置:

clientConfig.setGroupConfig(new GroupConfig("56015-56086-56176", "56015-56086-56176"));

更新:确保 Hazelcast 成员在服务器端采用正确的配置文件。默认情况下,它会在当前目录中搜索hazelcast.xml。您可以显式提供路径 - 可以使用编程方式:

Config config = new XmlConfigBuilder("/path/to/hazelcast.xml").build();
HazelcastInstance hz = Hazelcast.newHazelcastInstance(config);

或者,如果您使用简单的 Hazelcast.newHazelcastInstance(),您可以通过 hazelcast.config 系统属性来控制它:

java -Dhazelcast.config=/path/to/hazelcast.xml ...

关于java - AuthenticationException : Invalid credentials! 在 Hazelcast 中使用正确的凭据时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57796214/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com