-
Notifications
You must be signed in to change notification settings - Fork 392
Closed
Labels
Description
void bug() {
rpc::client c("localhost", port);// assume server not connected
c.set_timeout(1000);
// could call c.get_connection_state() to check if it's rpc::client::connection_state::connected but that's brittle and could run into bugs when it gets disconnected right after we check
auto res = c.call("fun").as<string>(); // hangs instead of timout exception
}
another example is when server disconnects:
void bug() {
rpc::client c("localhost", port);
c.set_timeout(1000);
// could call c.get_connection_state() to check if it's rpc::client::connection_state::connected but that's brittle and could run into bugs when it gets disconnected right after we check
while(true){
auto res = c.call("fun").as<string>(); // hangs when server disconnects instead of timout exception
// maybe sleep a bit here
// assume server gets disconnected at some point
}
}
EDIT: adding a check on get_connection_state doesn't even help because initally state is initial
if(c.get_connection_state()==rpc::client::connection_state::connected){
// won't get inside here, initially state is `initial`
auto res = c.call("fun").as<string>();
}
so looks like timeout
isnt' currently very useful; any workaround?