Reputation: 53551
I generated the client for Cassandra 1.0.8 using Thrift 0.8. I then tried the following example. The transport.open() passes, however I can't describe_keyspace or set_keyspace
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
This is the exception that I get
An unhandled exception of type 'Thrift.Transport.TTransportException' occurred in Thrift.dll
Additional information: Cannot read, Remote side has closed
I can connect to the keyspace using the CLI. Is there something wrong that I am doing? Does the client only work with certain versions? Has anyone successfully connected to the latest Cassandra using Thrift and C#?
Upvotes: 1
Views: 883
Reputation: 476
The issue is with transport.Open() The following works,
TSocket socket = null;
TTransport transport = null;
socket = new TSocket("localhost", 9160);
transport = new TFramedTransport(socket);
TProtocol protocol = new TBinaryProtocol(transport);
CassandraClient cassandraClient = new CassandraClient(protocol);
cassandraClient.InputProtocol.Transport.Open();
string s = cassandraClient.describe_cluster_name();
List<KsDef> keyspaces = cassandraClient.describe_keyspaces();
Use cassandraClient.InputProtocol.Transport.Open(); rather than transport.open()
Upvotes: 1
Reputation: 3684
Cassandra builds it's thrift bindings using thrift 0.7 which is almost certainly your problem. If you want to build your own thrift bindings you should use that version of thrift.
As psanford mentioned, you should most likely be using a higher level client. See:
http://wiki.apache.org/cassandra/ClientOptions
Upvotes: 2