Hi All,
I implemented a thrift client/server both in c++. I use Thrift version 0.11.
This is the client code to connect to the server:
void RpcDaemonHandler::connect()
{
boost::shared_ptr<apache::thrift::transport::TSocket> socket(new
apache::thrift::transport::TSocket(ipAddress.c_str(),
g_DaemonService_constants.DaemonService_port));
socket->setConnTimeout(connectionTimeout);
transport =
boost::make_shared<apache::thrift::transport::TBufferedTransport>(socket);
client =
boost::make_shared<DaemonServiceClient>(boost::make_shared<apache::thrift::protocol::TBinaryProtocol>(transport));
try {
transport->open();
} catch (apache::thrift::TException& exception) {
printf("ERROR: %s\n", exception.what());
}
}
And it works fine. Then I implemented a method to get the host name via
thrift and it works fine but for one host.
std::string RpcDaemonHandler::hostName()
{
std::string name;
if (isDaemonRunning()) {
client->getName(name);
}
return name;
}
The client->getName() call never returns. It seems locked somewhere but
I don't know where.
If I remember correctly I can debug the code till "readSlow" of the
TBufferTransposr.h.
uint32_t read(uint8_t* buf, uint32_t len) {
uint8_t* new_rBase = rBase_ + len;
if (TDB_LIKELY(new_rBase <= rBound_)) {
std::memcpy(buf, rBase_, len);
rBase_ = new_rBase;
return len;
}
return readSlow(buf, len);
}
I don't know what happens on the host, may be the firewall is involved.
But is there a way to set a timeout or so to prevent the client call to
hang the application?
Best regards,
Gianni