Closed oldn123 closed 1 year ago
这个可能是服务端把客户端关闭了,你初始化server的时候把server 超时时间设置为0,server就不会主动关client了
这个可能是服务端把客户端关闭了,你初始化server的时候把server 超时时间设置为0,server就不会主动关client了
你好,我试了下,把svr端构造时的超时时间增大可以解决这个问题,多谢。 这个“超时”的概念,是指客户端到服务端或者服务端到客户端没有任何消息发送超过xx秒后,服务端就会断开该客户端是吧?
是的,多少秒没收到消息后会关闭连接。
我测试demo里的一段逻辑,把请求的超时改成了0,预期应该会一直等待的吧,但是过一会儿会触发超时(服务端的pack_and_response未调用)。
void test_callback() { rpc_client client; bool r = client.connect("127.0.0.1", 9000);
for (size_t i = 0; i < 10; i++) { std::string test = "test" + std::to_string(i + 1); // set timeout 100ms client.async_call<0>( "async_echo", [](const asio::error_code &ec, string_view data) { if (ec) { //过一会儿这里会超时 std::cout << ec.value() << " timeout" << std::endl; return; }
client.run(); }