实现Thrift API时出错(Error implementing the Thrift API)
我正在用Java实现Thrift Remote Procedure调用框架。 我设置了thrift并生成了我的框架代码而没有太多问题,但是现在我实际上在使用API方法,我得到了奇怪的错误。
以下是我得到的错误:
Exception in thread "main" org.apache.thrift.transport.TTransportException: Cannot write to null outputStream at org.apache.thrift.transport.TIOStreamTransport.write(TIOStreamTransport.java:142) at org.apache.thrift.protocol.TBinaryProtocol.writeI32(TBinaryProtocol.java:163) at org.apache.thrift.protocol.TBinaryProtocol.writeMessageBegin(TBinaryProtocol.java:91) at SimonSays$Client.send_registerClient(SimonSays.java:102) at SimonSays$Client.registerClient(SimonSays.java:96) at simon.main(testClass.java:16)
我不认为我没有犯任何错误,但只是为了确保,这是导致错误的代码:
TProtocol prot = new TBinaryProtocol(new TSocket("http://thriftpuzzle.facebook.com",9030)); SimonSays.Client client = new SimonSays.Client(prot); client.registerClient("userEmailAddress@gmail.com");
该错误据说是从
client.registerClient()
调用生成的,但这是对Thrift生成的代码的调用,这让我觉得我在设置连接本身时做错了。关于制作
TProtocol
实例的部分我自己也包括在内,这可能就是问题所在。我希望有人能更多地了解我做错了什么。
如果需要更多信息或说明,请告诉我。
编辑:我从Cassandra Wiki找到了
TProtocol
实例化语句I'm implementing the Thrift Remote Procedure call framework in Java. I set up thrift and generated my skeleton code without a lot of issues, but now that I'm actually using the API methods, I get strange errors.
Here are the errors I get:
Exception in thread "main" org.apache.thrift.transport.TTransportException: Cannot write to null outputStream at org.apache.thrift.transport.TIOStreamTransport.write(TIOStreamTransport.java:142) at org.apache.thrift.protocol.TBinaryProtocol.writeI32(TBinaryProtocol.java:163) at org.apache.thrift.protocol.TBinaryProtocol.writeMessageBegin(TBinaryProtocol.java:91) at SimonSays$Client.send_registerClient(SimonSays.java:102) at SimonSays$Client.registerClient(SimonSays.java:96) at simon.main(testClass.java:16)
I don't think I'm not making any mistakes, but just to make sure, here's the code that's leading to the errors:
TProtocol prot = new TBinaryProtocol(new TSocket("http://thriftpuzzle.facebook.com",9030)); SimonSays.Client client = new SimonSays.Client(prot); client.registerClient("userEmailAddress@gmail.com");
The error is said to be generated from the
client.registerClient()
call, but that is a call to the code generated by Thrift, which makes me feel that I'm doing something wrong in setting up the connection itself.The part about making a
TProtocol
instance I included myself, and it's likely that that's where the problem lies.I was hoping that someone would have more of an idea about what's going wrong that I do.
Please let me know if more information or clarification is needed.
Edit: I found the
TProtocol
instantiation statement from the Cassandra Wiki
满意答案
您需要在
TSocket
实例上调用open()
方法,以便连接并获取所需的输入/输出流。资料来源: TSocket.java
You need to call the
open()
method on yourTSocket
instance in order for it to connect and obtain the input/output streams it needs.Source: TSocket.java
相关问答
更多相当于Twitter的Thrift API for .NET(Equivalent of Twitter Thrift API for .NET)
实现Thrift API时出错(Error implementing the Thrift API)
使用Thrift和php在Cassandra中创建二级索引(Creating Secondary Indexes in Cassandra using Thrift and php)
Thrift RPC从c#中的thrift客户端故障转移到通过HBase服务器转换的thrift服务器(Thrift RPC failing from a thrift client in c# to a thrift server spinned over HBase server)
出于什么原因,使用Thrift API进行Cassandra访问是不可取的?(For what reasons it is not preferable to use Thrift API for Cassandra access?)
在Thrift API和CQL之间混淆(Confusing between Thrift API and CQL)
在iOS中实现Thrift服务器(Implementing Thrift Server in iOS)
使用Thrift和Delphi Win32(Using Thrift with Delphi Win32)
Apache Thrift api采取cassandra快照[关闭](Apache Thrift api to take cassandra snapshot [closed])
使用Apache Thrift和TServlet执行服务多路复用(Perform service multiplexing with Apache Thrift and TServlet)
相关文章
更多Hadoop的thrift server配置
Storm-源码分析- Thrift的使用
POI 操作 Excel的主要API
java API 操作 Zookeeper
微信API 引用
分享一个免费的聊天api
快速预览 Jsoup API
POI核心API
JFreeChart核心API
最新问答
更多Python / IPython奇怪的不可重现列表索引超出范围错误(Python/IPython strange non reproducible list index out of range error)
故事板从表格单元中延伸出来并显示其详细信息披露按钮(storyboard segue from a tablecell an its Detail Disclosure Button)
我们可以将Gherkin功能文件与testcomplete集成(Can we integrate Gherkin feature files with testcomplete)
TrustAllCertificatesCallback被忽略(TrustAllCertificatesCallback is ignored)
返回嵌套元素的索引(Return index of nested element)
在数组中重新编号元素的有效方法(Efficient way of re-numbering elements in an array)
Express app定义的`static`文件夹无法正常工作(Express app defined `static` folder not working properly)
Javascript错误:未捕获TypeError:无法读取null的属性'value'[duplicate](Javascript error: Uncaught TypeError: Cannot read property 'value' of null [duplicate])
使用node.js和socket.io每秒广播一次(Using node.js and socket.io to broadcast every second)
如何让XMLSerializer将命名空间添加到嵌套对象中的属性?(How do I get the XMLSerializer to add namespaces to attributes in nested objects?)
Copyright ©2023 656463.com All Rights Reserved.滇ICP备2022006988号-50
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们,本站将尽快处理。谢谢合作!