thrift: changing from tSimpleServer to TNonblockingServer(thrift:从 tSimpleServer 更改为 TNonblockingServer)
问题描述
I have a simple thrift server:
shared_ptr<TProcessor> processor(new MyProcessor(handlerTrace));
shared_ptr<TServerTransport> serverTransport(new TServerSocket(port));
shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());
shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
TSimpleServer server(processor, serverTransport,
transportFactory, protocolFactory);
and able to connect with the following lines:
boost::shared_ptr<TSocket> socket(new TSocket("localhost", port));
boost::shared_ptr<TTransport> transport(new TBufferedTransport(socket));
boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
MyClient client(protocol);
Now I want to change the server to TNonblockingServer
. Therefore I changed the server code to the following:
shared_ptr<TServerTransport> serverTransport(new TServerSocket(port));
shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
TNonblockingServer server(processor,
protocolFactory,
port);
The client is unchanged. Now the server complaints about the client with the following error message:
Thrift: Mon Aug 19 22:55:43 2013 TNonblockingServer: Serving on port 9990, 1 io threads.
Thrift: Mon Aug 19 22:55:43 2013 TNonblockingServer: using libevent 2.0.16-stable method epoll
Thrift: Mon Aug 19 22:55:43 2013 TNonblocking: IO thread #0 registered for listen.
Thrift: Mon Aug 19 22:55:43 2013 TNonblocking: IO thread #0 registered for notify.
Thrift: Mon Aug 19 22:55:43 2013 TNonblockingServer: IO thread #0 entering loop...
Thrift: Mon Aug 19 22:55:48 2013 TNonblockingServer: frame size too large (2147549185 > 268435456) from client <Host: 127.0.0.1 Port: 57130>. Remote side not using TFramedTransport?
What do I do wrong? Comments? I am using the 1.0-dev version of thrift as only this version supports multiplexing..
Try using TFramedTransport instead of TBufferedTransport in your client. Look at this example: http://wiki.apache.org/thrift/ThriftUsageC%2B%2B
Another thing to notice is that according to the example above TNonblockingServer takes a ThreadManager as an argument.
这篇关于thrift:从 tSimpleServer 更改为 TNonblockingServer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:thrift:从 tSimpleServer 更改为 TNonblockingServer


基础教程推荐
- C语言数组 1970-01-01
- 明确指定任何或所有枚举数的整数值 1970-01-01
- C语言3个整数的数组 1970-01-01
- 对 STL 容器的安全并行只读访问 2022-10-25
- C++多态 1970-01-01
- 向量<unique_ptr<A>>使用初始化列表 2022-10-23
- 迭代std :: bitset中真实位的有效方法? 2022-10-18
- 总计将在节日礼物上花多少钱 1970-01-01
- C++:为什么结构类需要一个虚拟方法才能成为多态? 2022-10-19
- 用指数格式表示浮点数 1970-01-01