我使用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