Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Thrift.Transport.TTTransportException:无法写入null outputstream_C#_Cassandra_Thrift - Fatal编程技术网

C# Thrift.Transport.TTTransportException:无法写入null outputstream

C# Thrift.Transport.TTTransportException:无法写入null outputstream,c#,cassandra,thrift,C#,Cassandra,Thrift,我正在与卡桑德拉和节俭图书馆合作。我意识到这些都是非常早期的库,并且(毫无疑问)在某个时候会发生变化 我一直在使用下面的帮助来设置我的C#代码,以便在我的Cassandra服务器(我在本地VirtualBox的Ubuntu服务器实例中运行了该服务器)之间进行读写。我已经证实了这个简单的读/写功能是有效的 我遇到的问题是执行以下方法(该方法是使用Cassandra附带的thrift.definition文件为我生成的): 这是我的设置代码: TTransport _transport; TProt

我正在与卡桑德拉和节俭图书馆合作。我意识到这些都是非常早期的库,并且(毫无疑问)在某个时候会发生变化

我一直在使用下面的帮助来设置我的C#代码,以便在我的Cassandra服务器(我在本地VirtualBox的Ubuntu服务器实例中运行了该服务器)之间进行读写。我已经证实了这个简单的读/写功能是有效的

我遇到的问题是执行以下方法(该方法是使用Cassandra附带的thrift.definition文件为我生成的):

这是我的设置代码:

TTransport _transport;
TProtocol _protocol;
Cassandra.Client _client;

public Test()
{
    _transport = new TSocket("192.168.56.101", 9160);
    _protocol = new TBinaryProtocol(_transport);
    _client = new Cassandra.Client(_protocol);
}
我的呼叫代码如下所示:

public void GetAllBlogEntries()
    {
        var timestamp = DateTime.Now.Millisecond;
        var keyspace = "Keyspace1";

        var utf8Encoding = System.Text.Encoding.UTF8;

        var columnParent = new ColumnParent() {Column_family = "BlogEntries"};
        var predicate = new SlicePredicate()
        {
            Slice_range = new SliceRange()
                          {
                              Start = new byte[0],
                              Finish = new byte[0],
                              Count = 10,
                              Reversed = false
                          }
        };

        var results = _client.get_range_slice(keyspace, columnParent, predicate, "", "", 5, ConsistencyLevel.ONE);

        foreach(var slice in results)
        {
            Console.WriteLine("Found Key: {0}", slice.Key);
            foreach(var resultColumn in slice.Columns)
            {
                var column = resultColumn.Column;
                Console.WriteLine("\tName: {0}, value: {1}",
                                  utf8Encoding.GetString(column.Name),
                                  utf8Encoding.GetString(column.Value));                        
            }
        }
    } 
此方法的第一行是获取异常的位置:

oprot_.WriteMessageBegin(new TMessage("get_count", TMessageType.Call, seqid_));
这里有一个例外:

oprot_.WriteMessageBegin(new TMessage("get_count", TMessageType.Call, seqid_));
Thrift.Transport.TTTransportException:无法写入null outputstream at Thrift.Transport.TStreamTransport.Write(字节[]buf,Int32 off,Int32 len) at Thrift.Protocol.TBinaryProtocol.WriteI32(Int32 i32) 在Thrift.Protocol.TBinaryProtocol.WriteMessageBegin(TMessage message)中 在Cassandra.cs中的Apache.Cassandra.Cassandra.Client.send_get_range_slice(字符串键空间、列父列、切片谓词谓词、字符串开始键、字符串结束键、Int32行计数、一致性级别一致性级别):第341行 在Cassandra.cs中的Apache.Cassandra.Cassandra.Client.get_range_切片(字符串键空间、列父列、切片谓词谓词、字符串开始键、字符串结束键、Int32行计数、一致性级别一致性级别):第335行 在Test.cs中的CassandraDemo.Models.Test.GetAllBlogEntries()处:第212行 在TestTest.cs中的CassandraDemo.Tests.Models.testtesttest.Test_GetAllBlogEntries_Success():第42行


有什么想法吗?

您需要在传输上调用Open()。

听起来输出流是空的。如何初始化_client?@Schildmeijer我将使用我的设置代码进行更新。这个对象肯定是被创建的,因为我可以在调用这个代码之前读写。我认为实际上使用C#中Cassandra的人中没有人是这样的,所以如果你不能在这里找到它,试着询问Cassandra用户的邮件列表。就这样!我昨晚在回家的火车上发现了这一点,但我刚回去工作去检查。谢谢你的帮助!