我有一个简单的用例,其中一个节点应该能够使用主题将消息发布到另一个节点。我可以在Hazelcast中使用简单的客户端 - 服务器通信模式来完成此操作。但是,当我在客户端和服务器上启用SSL时,我在客户端获得此异常
java.lang.IllegalStateException: Cannot get initial partitions!
at com.hazelcast.client.spi.impl.ClientPartitionServiceImpl.getInitialPartitions(ClientPartitionServiceImpl.java:100) ~[hazelcast-client-3.2.6.jar:3.2.6]
at com.hazelcast.client.spi.impl.ClientPartitionServiceImpl.start(ClientPartitionServiceImpl.java:60) ~[hazelcast-client-3.2.6.jar:3.2.6]
at com.hazelcast.client.HazelcastClient.start(HazelcastClient.java:223) ~[hazelcast-client-3.2.6.jar:3.2.6]
at com.hazelcast.client.HazelcastClient.newHazelcastClient(HazelcastClient.java:186) ~[hazelcast-client-3.2.6.jar:3.2.6]
,服务器在日志中打印以下内容
09/29/2014 14:40:06.806 [hz.defaulttenant-defaultorg0.IO.thread-Acceptor - platform] INFO c.h.nio.TcpIpConnectionManager - [x.x.x.x]:5702 [defaulttenant-defaultorg0] [3.2.6] Established socket connection between /x.x.x.x:5702 and /x.x.x.x:55831
09/29/2014 14:40:16.844 [hz.defaulttenant-defaultorg0.IO.thread-Acceptor - platform] INFO com.hazelcast.nio.SocketAcceptor - [x.x.x.x]:5702 [defaulttenant-defaultorg0] [3.2.6] Accepting socket connection from /x.x.x.x:55832
09/29/2014 14:40:16.845 [hz.defaulttenant-defaultorg0.IO.thread-Acceptor - platform] INFO c.h.nio.TcpIpConnectionManager - [x.x.x.x]:5702 [defaulttenant-defaultorg0] [3.2.6] Established socket connection between /x.x.x.x:5702 and /x.x.x.x:55832
09/29/2014 14:40:21.847 [hz.defaulttenant-defaultorg0.IO.thread-Acceptor - platform] INFO com.hazelcast.nio.SocketAcceptor - [x.x.x.x]:5702 [defaulttenant-defaultorg0] [3.2.6] Accepting socket connection from /x.x.x.x:55833
09/29/2014 14:40:21.847 [hz.defaulttenant-defaultorg0.IO.thread-Acceptor - platform] INFO c.h.nio.TcpIpConnectionManager - [x.x.x.x]:5702 [defaulttenant-defaultorg0] [3.2.6] Established socket connection between /x.x.x.x:5702 and /x.x.x.x:55833
我已通过config xml
在服务器端启用了SSL <ssl enabled="true">
<factory-class-name>com.hazelcast.nio.ssl.BasicSSLContextFactory</factory-class-name>
<properties>
<property name="keyStore">cert.jks</property>
<property name="keyStorePassword">password</property>
<property name="keyManagerAlgorithm">SunX509</property>
<property name="trustManagerAlgorithm">SunX509</property>
<property name="protocol">TLS</property>
</properties>
</ssl>
,客户端使用以下代码访问服务器
ClientConfig clf = new ClientConfig();
clf.getNetworkConfig().addAddress("x.x.x.x:5702");
clf.getGroupConfig().setName("grp-name");
clf.getGroupConfig().setPassword("password");
clf.getNetworkConfig().setSSLConfig(NodeCommUtil.getSSLConfig());
clf.getNetworkConfig().setSocketOptions(socketOptions);
HazelcastInstance client = HazelcastClient.newHazelcastClient(clf);
public static SSLConfig getSSLConfig() throws IOException, ClassNotFoundException, NoSuchMethodException, SecurityException,
IllegalAccessException, IllegalArgumentException, InvocationTargetException {
SSLConfig sslConfig = new SSLConfig();
sslConfig.setEnabled(true);
sslConfig.setFactoryClassName("com.hazelcast.nio.ssl.BasicSSLContextFactory");
Properties props = new Properties();
ClassPathResource r = new ClassPathResource("cert.jks");
props.setProperty("keyStore", "/" + r.getFile().getAbsolutePath());
props.setProperty("keyStorePassword", "password");
props.setProperty("keyManagerAlgorithm", "SunX509");
props.setProperty("trustManagerAlgorithm", "SunX509");
props.setProperty("protocol", "tls");
sslConfig.setProperties(props);
return sslConfig;
}
客户和客户服务器能够相互通信。事实上,如果我禁用SSL就像魅力一样。非常感谢任何帮助。
答案 0 :(得分:0)
SSL已被删除。
你在服务器上使用哪个HZ版本btw?