Hazelcast客户端的AuthenticationException [英] AuthenticationException from Hazelcast client

查看:166
本文介绍了Hazelcast客户端的AuthenticationException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试通过客户端连接Hazelcast服务器时,它给了我很多启示.

When I am trying to connect Hazelcast server through client, it gives me following exeption.

com.hazelcast.client.AuthenticationException: Invalid credentials!
    at com.hazelcast.client.spi.impl.ClusterListenerSupport$ManagerAuthenticator.authenticate(ClusterListenerSupport.java:153)
    at com.hazelcast.client.connection.nio.ClientConnectionManagerImpl.authenticate(ClientConnectionManagerImpl.java:249)
    at com.hazelcast.client.connection.nio.ClientConnectionManagerImpl.initializeConnection(ClientConnectionManagerImpl.java:220)
    at com.hazelcast.client.connection.nio.ClientConnectionManagerImpl.getOrConnect(ClientConnectionManagerImpl.java:211)
    at com.hazelcast.client.connection.nio.ClientConnectionManagerImpl.getOrConnect(ClientConnectionManagerImpl.java:67)
    at com.hazelcast.client.spi.impl.ClusterListenerSupport.connect(ClusterListenerSupport.java:241)
    at com.hazelcast.client.spi.impl.ClusterListenerSupport.connectToOne(ClusterListenerSupport.java:209)
    at com.hazelcast.client.spi.impl.ClusterListenerSupport.connectToCluster(ClusterListenerSupport.java:161)
    at com.hazelcast.client.spi.impl.ClientClusterServiceImpl.start(ClientClusterServiceImpl.java:203)
    at com.hazelcast.client.impl.HazelcastClientInstanceImpl.start(HazelcastClientInstanceImpl.java:303)
    at com.hazelcast.client.HazelcastClient.newHazelcastClient(HazelcastClient.java:86)

尝试使用组名称为dev1的方式.我的服务器在Linux系统上.这是Windows系统中的客户端配置.

Trying with group name as dev1. My server is on Linux system. And here is client configurations from Windows system.

<?xml version="1.0" encoding="UTF-8"?>
<hazelcast-client xsi:schemaLocation="http://www.hazelcast.com/schema/client-config hazelcast-client-config-3.6.xsd"
                  xmlns="http://www.hazelcast.com/schema/client-config"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <group>
        <name>dev1</name>
        <password>dev-pass</password>
    </group>
    <license-key>HAZELCAST_ENTERPRISE_LICENSE_KEY</license-key>
    <properties>
        <property name="hazelcast.client.shuffle.member.list">true</property>
        <property name="hazelcast.client.heartbeat.timeout">60000</property>
        <property name="hazelcast.client.heartbeat.interval">5000</property>
        <property name="hazelcast.client.event.thread.count">5</property>
        <property name="hazelcast.client.event.queue.capacity">1000000</property>
        <property name="hazelcast.client.invocation.timeout.seconds">120</property>
    </properties>
    <network>
        <cluster-members>
            <address>192.168.2.49</address>
            <address>192.168.5.67</address>
        </cluster-members>
        <smart-routing>true</smart-routing>
        <redo-operation>true</redo-operation>
        <connection-timeout>60000</connection-timeout>
        <connection-attempt-period>3000</connection-attempt-period>
        <connection-attempt-limit>2</connection-attempt-limit>
        <socket-options>
            <tcp-no-delay>false</tcp-no-delay>
            <keep-alive>true</keep-alive>
            <reuse-address>true</reuse-address>
            <linger-seconds>3</linger-seconds>
            <timeout>-1</timeout>
            <buffer-size>32</buffer-size>
        </socket-options>        
        <ssl enabled="false">
            <factory-class-name>com.hazelcast.examples.MySslFactory</factory-class-name>
        </ssl>       
    </network>
    <executor-pool-size>40</executor-pool-size>
    <native-memory enabled="false" allocator-type="POOLED">
        <size unit="MEGABYTES" value="128" />
        <min-block-size>1</min-block-size>
        <page-size>1</page-size>
        <metadata-space-percentage>40.5</metadata-space-percentage>
    </native-memory>
    <load-balancer type="random"/>
    <near-cache name="default">
        <max-size>2000</max-size>
        <time-to-live-seconds>90</time-to-live-seconds>
        <max-idle-seconds>100</max-idle-seconds>
        <eviction-policy>LFU</eviction-policy>
        <invalidate-on-change>true</invalidate-on-change>
        <in-memory-format>OBJECT</in-memory-format>
        <local-update-policy>INVALIDATE</local-update-policy>
    </near-cache>
    <query-caches>
        <query-cache name="query-cache-name" mapName="map-name">
            <predicate type="class-name">com.hazelcast.examples.ExamplePredicate</predicate>
            <entry-listeners>
                <entry-listener include-value="true" local="false">com.hazelcast.examples.EntryListener</entry-listener>
            </entry-listeners>
            <include-value>true</include-value>
            <batch-size>1</batch-size>
            <buffer-size>16</buffer-size>
            <delay-seconds>0</delay-seconds>
            <in-memory-format>BINARY</in-memory-format>
            <coalesce>false</coalesce>
            <populate>true</populate>
            <eviction eviction-policy="LRU" max-size-policy="ENTRY_COUNT" size="10000"/>
            <indexes>
                <index ordered="false">name</index>
            </indexes>
        </query-cache>
    </query-caches>
</hazelcast-client>

我的配置有误吗?

这是客户代码

HazelcastInstance client = com.hazelcast.client.HazelcastClient.newHazelcastClient();
Map<Integer, String> customerMap = client.getMap("customers");

推荐答案

您的集群需要密码.你可以尝试:

Your cluster requires a password. Can you try:

    ClientConfig config = new ClientConfig();
    config.getGroupConfig().setPassword("dev-pass"); //that's the pw in your xml config.
    com.hazelcast.client.HazelcastClient.newHazelcastClient(config);

这篇关于Hazelcast客户端的AuthenticationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆