Closed chenzl-123 closed 5 months ago
代码段:
using namespace rest_rpc; int test() { rpc_client client("127.0.0.1", 9110); client.enable_auto_reconnect(); //automatic reconnect client.enable_auto_heartbeat(); if (!client.connect(30)) { printf("%s:connect error\r\n", FUNCTION); return -1; } try { bool bServerStat = false; if (false == client.has_connected()) { printf("%s:client is not connected\r\n", FUNCTION); return -2; } auto result = client.async_call("getServerStat"); if (result.wait_for(std::chrono::seconds(5)) == std::future_status::timeout) { return -3; } bServerStat = result.get().as(); } catch (const std::exception& ex) { printf("%s:call timeout, error message:%s\r\n", FUNCTION, ex.what()); return -4; } return 0; }
int main(int argc, char *argv[]) {
for (int nI = 0; nI < 100; nI++) { printf("111111111111111\r\n"); test(); printf("222222222222222\r\n"); } printf("success\r\n"); return 0;
}
已经fix了,请拉最新代码验证一下。
代码段:
include
include "rest_rpc.hpp"
using namespace rest_rpc; int test() { rpc_client client("127.0.0.1", 9110); client.enable_auto_reconnect(); //automatic reconnect client.enable_auto_heartbeat(); if (!client.connect(30)) { printf("%s:connect error\r\n", FUNCTION); return -1; } try { bool bServerStat = false; if (false == client.has_connected()) { printf("%s:client is not connected\r\n", FUNCTION); return -2; } auto result = client.async_call("getServerStat");
if (result.wait_for(std::chrono::seconds(5)) == std::future_status::timeout) {
return -3;
}
bServerStat = result.get().as();
}
catch (const std::exception& ex) {
printf("%s:call timeout, error message:%s\r\n", FUNCTION, ex.what());
return -4;
}
return 0;
}
int main(int argc, char *argv[]) {
}