title: Thrift.Transport.TTransportException: Cannot write to null outputstream
body: <p>I'm doing some work with Cassandra and the Thrift libraries. I realize these are very early libraries and will (undoubtedly) change at some point. </p>
  
  <p>I've been using the following <a href="http://it.toolbox.com/people/joshschulz/journal-entry/4720" rel="noreferrer">link</a> for help with setting up my C# code to write and read to and from my Cassandra server (which I have running in an Ubuntu Server instance in my local VirtualBox). I've confirmed that the trivial read / write functionality works.</p>
  
  <p>Where I'm having a problem is executing the following method (which was generated for me using the thrift.definition file that came with Cassandra):</p>
  
  <pre><code>public void send_get_count(string keyspace, string key, ColumnParent column_parent, ConsistencyLevel consistency_level)
  </code></pre>
  
  <p>Here's my setup code:</p>
  
  <pre><code>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);
  }
  </code></pre>
  
  <p>My calling code looks like so:</p>
  
  <pre><code>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));                        
              }
          }
      } 
  </code></pre>
  
  <p>The first line of this method is where I am getting my exception:</p>
  
  <pre><code>oprot_.WriteMessageBegin(new TMessage("get_count", TMessageType.Call, seqid_));
  </code></pre>
  
  <p>And here is the exception:</p>
  
  <p>Thrift.Transport.TTransportException: Cannot write to null outputstream
  at Thrift.Transport.TStreamTransport.Write(Byte[] buf, Int32 off, Int32 len)
  at Thrift.Protocol.TBinaryProtocol.WriteI32(Int32 i32)
  at Thrift.Protocol.TBinaryProtocol.WriteMessageBegin(TMessage message)
  at Apache.Cassandra.Cassandra.Client.send_get_range_slice(String keyspace, ColumnParent column_parent, SlicePredicate predicate, String start_key, String finish_key, Int32 row_count, ConsistencyLevel consistency_level) in Cassandra.cs: line 341
  at Apache.Cassandra.Cassandra.Client.get_range_slice(String keyspace, ColumnParent column_parent, SlicePredicate predicate, String start_key, String finish_key, Int32 row_count, ConsistencyLevel consistency_level) in Cassandra.cs: line 335
  at CassandraDemo.Models.Test.GetAllBlogEntries() in Test.cs: line 212
  at CassandraDemo.Tests.Models.TestTest.Test_GetAllBlogEntries_Success() in TestTest.cs: line 42 </p>
  
  <p>Any ideas?</p>