报错信息:
terminate called after throwing an instance of 'apache::thrift::transport::TTransportException'
what(): Frame size has negative value
错误定位:
clinet调用sever端接口时卡死。
eg:
Ia10kThriftClient<common::api::thrift::TestClient> client;
void ClientInit()
{
client.create(IP, POST, NAME);
client.setTimeout(10000, 10000, 10000);
client.open();
}
void callback(const int id, const Data::data)
{
boost::call_once(once_TOOLClientInit, &TOOLClientInit);
try
{
cout<<"###add by zcq###start"<<endl;
client->ResultData(id, data);
cout<<"###add by zcq###end"<<endl;
//usleep(1000); //1毫秒
}
catch (boost::bad_get&)
{
ISFLOG_ERROR << "callback reslut error";
return;
}
}
多线程调用,或者callback调用频繁,会导致以上报错,现象为,执行到ResultData函数此语句时,会出现两个start却没有end,猜想可能是由于thrift内部资源死锁导致,有那位高人若知望指出哈。
解决方法:
在callback中加锁。(当时不知道,苦苦撑了好几天,撸了好多代码,走了好多弯路,说多了都是泪呀)
boost::unique_lock<boost::mutex> lock(mutex);
报错信息:
clinet端报错:
terminate called after throwing an instance of 'apache::thrift::TApplicationException'
what(): Unknown function Media:mediaResultPictureData
解决方法:
server用python
client用C++,但是python中的server有多种方法:
# server = TServer.TSimpleServer(tMultiplexedProcessor, transport, tfactory, pfactory)
# server = TServer.TThreadPoolServer(tMultiplexedProcessor, transport, tfactory, pfactory)
server = TServer.TThreadedServer(processor, transport, tfactory, pfactory)
# server = TServer.TForkingServer(processor, transport, tfactory, pfactory)
# server = TServer.TNonblockingServer(processor, transport, tfactory, pfactory)
至于和C++之中有什么关系有待进一步研究。。。
使用
TServer.TSimpleServer【python】搞定