qicosmos / rest_rpc

modern C++(C++11), simple, easy to use rpc framework
MIT License
1.66k stars 365 forks source link

频繁重启设备会导致客户端connect奔溃。 #63

Open chenzl-123 opened 2 years ago

chenzl-123 commented 2 years ago

terminate called after throwing an instance of 'std::future_error' what(): std::future_error: Broken promise 求大佬指点下。

chenzl-123 commented 2 years ago

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;

}

chenzl-123 commented 2 years ago

源码附上

qicosmos commented 2 years ago

测试方法是频繁重启server吗?

chenzl-123 commented 2 years ago

服务端和客户端同时启动