- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在试验使用 Visual Studio 2015 用 C++ 编写的非常简单的 Apache Thrift 服务器和客户端。代码基于官方 Apache Thrift 示例。
我使用的是最新版本的 Thrift (0.10.0)、Boost (1.64.0) 和 OpenSSL (1.1.0e)。
从客户端到服务器的每次调用都会在 TTransport.h 第 43 行中触发 TTransportException:
throw TTransportException(TTransportException::END_OF_FILE, "No more data to read.");
这是我的 test.thrift 文件:
namespace cpp test
service Test {
void ping()
}
thrift 编译器生成 Test.h,它在下面#included 在服务器和客户端中(不显示实际代码,因为它是自动生成的)。
包含在客户端和服务器中的 thrift 头文件:
#include <thrift/protocol/TBinaryProtocol.h>
#include <thrift/transport/TSocket.h>
#include <thrift/transport/TTransportUtils.h>
#include <thrift/server/TSimpleServer.h>
#include <thrift/transport/TServerSocket.h>
#include <thrift/transport/TBufferTransports.h>
#include <Test.h>
客户端主要:
using namespace ::apache::thrift;
using namespace ::apache::thrift::protocol;
using namespace ::apache::thrift::transport;
using namespace ::apache::thrift::server;
using namespace std;
int main()
{
boost::shared_ptr<TTransport> socket(new TSocket("localhost", 9090));
boost::shared_ptr<TTransport> transport(new TFramedTransport(socket));
boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
test::TestClient client(protocol);
try {
transport->open();
client.ping();
cout << "ping()" << endl;
transport->close();
}
catch (TException& tx) {
cout << "ERROR: " << tx.what() << endl;
}
return 0;
}
和服务器主要:
using namespace ::apache::thrift;
using namespace ::apache::thrift::protocol;
using namespace ::apache::thrift::transport;
using namespace ::apache::thrift::server;
using namespace std;
class TestHandler : virtual public test::TestIf {
public:
TestHandler() {
// Your initialization goes here
}
void ping() {
// Your implementation goes here
printf("ping\n");
}
};
int main()
{
std::cout << "Starting thrift server thread" << std::endl;
int port = 9090;
boost::shared_ptr<TestHandler> handler(new TestHandler());
boost::shared_ptr<TProcessor> processor(new test::TestProcessor(handler));
boost::shared_ptr<TServerTransport> serverTransport(new TServerSocket(port));
boost::shared_ptr<TTransportFactory> transportFactory(new TFramedTransportFactory());
boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
boost::shared_ptr< apache::thrift::server::TSimpleServer > server = boost::shared_ptr< TSimpleServer>(new TSimpleServer(processor, serverTransport, transportFactory, protocolFactory));
server->serve();
return 0;
}
我也尝试使用 TBufferedTransport 和 TJSONProtocol 得到相同的结果。
抛出异常表明这不是正常运行,然而,调用被接收并处理(异常发生在调用TestHandler::ping()之后)并且服务器继续监听并接收请求(每次触发相同的错误),所以这是一个可恢复的条件。
所以我想知道为什么会发生这种情况,它是否可以/应该修复,以及如何,如果不是,尽管有这个异常,使用服务器是否安全。
最佳答案
按设计。
Thrift 库以这种方式实现,其中通过抛出 TTransportException
在内部发出连接结束信号。
关于c++ - 用 C++ 编写的 Apache Thrift 服务器抛出 TTransportException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43927521/
我遇到了这个异常,它没有任何特定的消息,例如“读取超时”、“连接拒绝”或“连接重置”。而且这个异常通常不会发生。 我想知道这个异常的根本原因是什么? org.apache.thrift.transpo
我们最近收到了很多 com.evernote.thrift.transport.TTransportException使用 HTTP 代码 400、429、418。 429 对应于 Too Many
我在尝试在 python 上使用 thrift 执行 RPC 时遇到奇怪的错误。我在网上发现了类似的问题,但没有一个真正适用于我的情况。 这是我遇到的错误 No handlers could be f
我对这个问题很困惑。我有一个 Apache Thrift 0.9.0 客户端和服务器。客户端代码如下: this.transport = new TSocket(this.server, this.p
hive 版本:0.13.1 pig 版本:0.13.0 我试图通过以下命令使用 pig 读取配置单元表。 grunt> DATA = LOAD 'dev.profile' USING org.apa
我正在为名为 jshs2 的 hive 使用 node.js 客户端驱动程序,但在连接到我们的 hiveserver2 时遇到连接问题。我试图查找无效状态 128,但没有成功。这是我的代码: cons
在我用 C# 编写的客户端中出现此错误。我的服务器在 python 中。这是我第一个使用 thrift 的测试程序。看起来我的 python 服务器正在运行。这是我的客户端代码。我在调用“Client
那里 我是Hive的新手,它是一个使用kerberos身份验证访问 hive 的Java应用程序,如下所示: try { System.setProperty(
我有Nifi 1.4.0和Hive 2.3.0。 Metastore Service运行正常,但由于某些原因Nifi无法执行PutHiveStreaming Processor。 以下是完整的堆栈。有
我连接到 Hive 并从表行中获取数据的 ID。当我连接到配置单元、发送请求并获得响应时,问题不会发生。但是当我从 ResultSet 获取 id 时,出现异常: org.apache.thrift.
我正在尝试获取位于 hive (hortonworks) 中的一个表,以收集一些 Twitter 数据以在机器学习项目上实现,使用 pyhive,因为 python3.6 不支持 pyhs2。 这是我
我正在使用 apache Thrift。我收到 TTransportException 异常,而我的代码看起来一切正常。这是我的 Thrift 服务器代码: private TNonblockingS
假设 Hive 安装在“g”集群中。我无权访问 Gold Cluster。我正在“s”集群中进行 python 开发工作。我可以从“s”集群访问 Hive 并运行查询。 我有以下代码可以从在“s”集群
这个错误是什么意思?“元数据错误:org.apache.thrift.transport.TTransportException?”在什么情况下会出现此错误? 我在创建表和将数据加载到表中时遇到此错误
我正在使用 Cassandra 和 Thrift 库做一些工作。我意识到这些是非常早期的库,并且(毫无疑问)会在某个时候发生变化。 我一直在使用以下 link寻求帮助设置我的 C# 代码以写入和读取我
我是使用 astyanax 连接到 cassandra(1.2.8)的新手。 我从 [https://github.com/Netflix/astyanax] 下载了 astyanax,从 [http
我使用的是最新版本的 Cassandra 1.1.2,并且我的 Cassandra 数据库中已有数据。我想通过以下方式更新列族的元数据: 更新列族注释,column_metadata = [{colu
我正在试验使用 Visual Studio 2015 用 C++ 编写的非常简单的 Apache Thrift 服务器和客户端。代码基于官方 Apache Thrift 示例。 我使用的是最新版本的
我正在尝试使用 java 在配置单元中创建表。我找到了 java.sql.SQLException:org.apache.thrift.transport.TTransportException 在执
我正在使用 hive-0.9.0 和 mysql 作为 Metastore。我得到一个异常(exception): hive> show tables; FAILED: Error in metada
我是一名优秀的程序员,十分优秀!