#include <hazelcast/client/HazelcastClient.h>
int main() {
hazelcast::client::ClientConfig config;
hazelcast::client::HazelcastClient hz(config);
std::cout << "Started the Hazelcast C++ client instance " << hz.getName() << std::endl;
}
但是它一直崩溃
我写了代码来测试连接(代码如上),但是显示这些消息却失败了>]
在客户端中
23/03/2020 18:23:37.421 INFO: [7436] hz.client_1[dev] [3.12.1] (NOT_FOUND:NOT_FOUND) LifecycleService::LifecycleEvent STARTING 23/03/2020 18:23:37.421 INFO: [7436] hz.client_1[dev] [3.12.1] LifecycleService::LifecycleEvent STARTED 23/03/2020 18:23:37.437 INFO: [12624] hz.client_1[dev] [3.12.1] Trying to connect to Address[127.0.0.1:5701] as owner member 23/03/2020 18:23:37.437 INFO: [7120] hz.client_1[dev] [3.12.1] ClientConnection{alive=0, connectionId=1, remoteEndpoint=null, lastReadTime=2020-03-23 09:23:37.462000, closedTime=2020-03-23 09:23:37.462000, connected server version=} closed. Reason: IOException {Connection closed by remote Error code:24} at TcpSocket::receive 23/03/2020 18:23:37.562 WARN: [12624] hz.client_1[dev] [3.12.1] Exception during initial connection to Address[127.0.0.1:5701], exception ExecutionException {Could not be authenticated. Error code:19, Caused by:IOException {Packet not sent to null Error code:24} at AbstractClientInvocationService::send} at AuthenticationFuture::get 23/03/2020 18:23:37.562 WARN: [12624] hz.client_1[dev] [3.12.1] Unable to get alive cluster connection, try in 2873 ms later, attempt 1 of 2. 23/03/2020 18:23:40.437 INFO: [12624] hz.client_1[dev] [3.12.1] Trying to connect to Address[127.0.0.1:5701] as owner member 23/03/2020 18:23:40.437 INFO: [7120] hz.client_1[dev] [3.12.1] ClientConnection{alive=0, connectionId=2, remoteEndpoint=null, lastReadTime=2020-03-23 09:23:40.458000, closedTime=2020-03-23 09:23:40.462000, connected server version=} closed. Reason: IOException {Connection closed by remote Error code:24} at TcpSocket::receive 23/03/2020 18:23:40.546 WARN: [12624] hz.client_1[dev] [3.12.1] Exception during initial connection to Address[127.0.0.1:5701], exception ExecutionException {Could not be authenticated. Error code:19, Caused by:IOException {Packet not sent to null Error code:24} at AbstractClientInvocationService::send} at AuthenticationFuture::get 23/03/2020 18:23:40.546 WARN: [12624] hz.client_1[dev] [3.12.1] Unable to get alive cluster connection, attempt 2 of 2. 23/03/2020 18:23:40.546 WARN: [12624] hz.client_1[dev] [3.12.1] Could not connect to cluster, shutting down the client. Unable to connect to any address! The following addresses were tried: { Address[127.0.0.1:5701] , } 23/03/2020 18:23:40.546 INFO: [7436] hz.client_1[dev] [3.12.1] LifecycleService::LifecycleEvent SHUTTING_DOWN 23/03/2020 18:23:41.328 INFO: [7436] hz.client_1[dev] [3.12.1] LifecycleService::LifecycleEvent SHUTDOWN
在服务器中
3 23, 2020 6:23:40 pm com.hazelcast.internal.nio.tcp.TcpIpConnection
경고: [172.16.253.101]:5701 [dev] [4.0] Connection[id=9, /127.0.0.1:5701->/127.0.0.1:50518, qualifier=null, endpoint=null, alive=false, connectionType=NONE] closed. Reason: Exception in Connection[id=9, /127.0.0.1:5701->/127.0.0.1:50518, qualifier=null, endpoint=null, alive=true, connectionType=NONE], thread=hz.heuristic_galileo.IO.thread-in-2
java.lang.IllegalStateException: Unknown protocol: CB2
at com.hazelcast.internal.nio.tcp.UnifiedProtocolDecoder.onRead(UnifiedProtocolDecoder.java:116)
at com.hazelcast.internal.networking.nio.NioInboundPipeline.process(NioInboundPipeline.java:137)
at com.hazelcast.internal.networking.nio.NioPipeline.lambda$start$0(NioPipeline.java:127)
at com.hazelcast.internal.networking.nio.NioThread.processTaskQueue(NioThread.java:354)
at com.hazelcast.internal.networking.nio.NioThread.selectLoop(NioThread.java:289)
at com.hazelcast.internal.networking.nio.NioThread.run(NioThread.java:248)
我曾尝试在Windows中使用#include
Hazelcast v4.0的cpp客户端尚未发布,并且客户端的3.x版本与其不兼容。您现在可以尝试在服务器中使用Hazelcast 3.x。