简体   繁体   中英

Apache Thrift timeout

I'm using apache thrift in version 0.13.0. As soon as the time between two calls is approximately 1.5 seconds the connection will be closed. The timeout varies from 1.3 to 1.8 seconds.

keepAlive is set in server and client. I tried different for rx, tx but this did not change anything. My client code used for testing is below. The client is using windows and the server is running linux.

  for (int i = 0; i < 100'000;i+=50){
    remote_method();
    auto sleep = std::chrono::milliseconds(i);
    std::cout << "Sleep: " << i << "\n";
    std::this_thread::sleep_for(sleep);
  }

Thrift will throw an exception in the code snippet below, which is located in TSocket.cpp

// Timed out!
    if (errno_copy == THRIFT_ETIMEDOUT) {
      throw TTransportException(TTransportException::TIMED_OUT, "THRIFT_ETIMEDOUT");
    }

It looks like something is resetting the connection after this time. If the method is called with a high frequency no timeout occurs.

Thrift is working correctly, other socket based communication is showing this behavior as well. The root cause was the VMware virtual machine the server was running in. The network mode (briged, NAT, or host only) did not make a difference. By moving the server to a physical machine the problem has been solved. Most likely the network configuration of the linux is faulty.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM