I have a client / server setup for Cassandra that works when accessed via Perl. Im trying to redo the process in PHP now. I can't seem to call any functions against my installation without getting a 'TSocket read 0 bytes' exception. Here is a sample that should be pretty straightforward:
$GLOBALS['THRIFT_ROOT'] = '/usr/local/src/thrift-0.8.0/lib/php/src';
require_once $GLOBALS['THRIFT_ROOT'].'/packages/cassandra/Cassandra.php';
require_once $GLOBALS['THRIFT_ROOT'].'/packages/cassandra/cassandra_types.php';
require_once $GLOBALS['THRIFT_ROOT'].'/transport/TSocket.php';
require_once $GLOBALS['THRIFT_ROOT'].'/protocol/TBinaryProtocol.php';
require_once $GLOBALS['THRIFT_ROOT'].'/transport/TFramedTransport.php';
require_once $GLOBALS['THRIFT_ROOT'].'/transport/TBufferedTransport.php';
try {
$socket = new TSocket( '10.127.24.19', 9160 );
$transport = new TBufferedTransport( $socket, 1024, 1024 );
$protocol = new TBinaryProtocolAccelerated( $transport );
$client = new cassandra_CassandraClient( $protocol );
$transport->open();
$keyspace = 'some_data';
$client->set_keyspace( $keyspace );
}
catch (TException $tx)
{
error_log( print_r( $tx, true ));
}
This is thrift 0.8.0, Cassandra 1.0, PHP 5.3.1.