diff --git a/include/client_util.hpp b/include/client_util.hpp index 5afc72d..3bce171 100644 --- a/include/client_util.hpp +++ b/include/client_util.hpp @@ -37,7 +37,9 @@ namespace rest_rpc { template inline T as(string_view result) { if (has_error(result)) { - throw std::logic_error("rpc error"); + rpc_service::msgpack_codec codec; + auto tp = codec.unpack>(result.data(), result.size()); + throw std::logic_error(std::get<1>(tp)); } return get_result(result); diff --git a/include/rpc_client.hpp b/include/rpc_client.hpp index dbb9241..cb0a264 100644 --- a/include/rpc_client.hpp +++ b/include/rpc_client.hpp @@ -118,7 +118,7 @@ namespace rest_rpc { void async_reconnect(){ reset_socket(); async_connect(); - std::this_thread::sleep_for(std::chrono::seconds(1)); + std::this_thread::sleep_for(std::chrono::milliseconds(connect_timeout_)); } bool connect(size_t timeout = 1) { @@ -520,7 +520,7 @@ namespace rest_rpc { std::string host_; unsigned short port_ = 0; - size_t connect_timeout_ = 2;//s + size_t connect_timeout_ = 2000;//s size_t wait_timeout_ = 2;//s int reconnect_cnt_ = -1; bool has_connected_ = false;