rest_rpc
rest_rpc copied to clipboard
频繁重启设备会导致客户端connect奔溃。
terminate called after throwing an instance of 'std::future_error' what(): std::future_error: Broken promise 求大佬指点下。
rest_rpc::rpc_client m_rpcClient
int start() {
int nCount = 0;
m_rpcClient.enable_auto_heartbeat(); // automatic heartbeat
m_rpcClient.connect("127.0.0.1", 8999);
while (nCount < 10) {
if (m_rpcClient.has_connected()) {
printf("netclient connect success\r\n");
break;
}
else {
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}
nCount++;
if (nCount == 10) {
printf("netclient connect failed\r\n");
return -1;
}
}
return 0;
}
源码附上
测试方法是频繁重启server吗?
服务端和客户端同时启动