我使用Thrift 0.8为Cassandra 1.0.8生成客户端。然后我尝试了下面的例子。该transport.open()传递,但我不能describe_keyspace或set_keyspace连接Thrift 0.8,Cassandra 1.0.8和C时的异常#
TTransport transport = new TBufferedTransport(new TSocket("localhost", 9160));
TProtocol protocol = new TBinaryProtocol(transport);
Cassandra.Client client = new Cassandra.Client(protocol);
Console.WriteLine("Opening connection");
try
{
transport.Open();
}
catch (Exception e)
{
Console.WriteLine("error connecting...");
return;
}
KsDef def = client.describe_keyspace("nm_example"); // error here
client.set_keyspace("nm_example");// error here
这是个例外,我得到
An unhandled exception of type 'Thrift.Transport.TTransportException' occurred in Thrift.dll
Additional information: Cannot read, Remote side has closed
我可以连接到使用CLI密钥空间。我在做什么不对?客户端是否只能使用某些版本?有人使用Thrift和C#成功连接到最新的Cassandra吗?
你真的应该使用更高级别的库,而不是直接使用thrift。我建议你看看http://code.google.com/p/cassandra-sharp/ – psanford 2012-04-02 18:15:42