rest_rpc icon indicating copy to clipboard operation
rest_rpc copied to clipboard

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

Open chenzl-123 opened this issue 2 years ago • 4 comments

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

chenzl-123 avatar Mar 07 '22 12:03 chenzl-123

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 avatar Mar 07 '22 13:03 chenzl-123

源码附上

chenzl-123 avatar Mar 07 '22 13:03 chenzl-123

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

qicosmos avatar Mar 08 '22 05:03 qicosmos

服务端和客户端同时启动

chenzl-123 avatar Mar 11 '22 03:03 chenzl-123