猿问

AuthenticationException:凭据无效!在 Hazelcast 中使用正确的凭据时

所以我使用 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);

获取频率配置:


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;

}


jeck猫
浏览 247回答 2
2回答

慕尼黑8549860

您的客户端配置使用密码"56086-56015-56176",但您的成员配置包含组密码"56015-56086-56176"。即第一部分和第二部分(破折号分隔)被交换。这是正确的客户端配置: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 ...

萧十郎

您的服务器有组名56015-56086-56176。您的客户有组名56086-56015-56176。三重奏的前两部分被调换。密码也一样。另请注意,从 3.8 开始,密码已被弃用
随时随地看视频慕课网APP

相关分类

Java
我要回答