0

I install cassandra on ubuntu, set in conf file

listen_address: 200.166.107.170

rpc_address: 213.186.117.170

rpc_port: 9160

then i try run this php code from other machine

CassandraConn::add_node('200.166.107.170', 9160);

$users = new CassandraCF('Keyspace1', 'Users');

$users->insert('1', array('email' => 'hoan.tonthat@gmail.com', 'password' => 'test'));

and as result have this

Fatal error: Uncaught exception 'Exception' with message 'Could not connect to a cassandra server' in C:\inetpub\wwwroot\phpcassa.php:85 Stack trace: #0 C:\inetpub\wwwroot\phpcassa.php(283): CassandraConn::get_client() #1 C:\inetpub\wwwroot\cassandra_test.php(31): CassandraCF->insert('1', Array) #2 {main} thrown in C:\inetpub\wwwroot\phpcassa.php on line 85

what can be a cause of this error? Thanks

lebron2323
  • 990
  • 2
  • 14
  • 29

1 Answers1

1

Ensure you are using the version of PHPCassa distributed by thobbs:

From the tutorial:

 $servers = array("192.168.2.1:9160");
 $pool = new ConnectionPool("Keyspace1", $servers);
 $column_family = new ColumnFamily($pool, 'ColumnFamily1');

Failing this, what version of Apache Cassandra are you using?

** Update **

Turns out that you are trying to connect to Cassandra on the LISTEN_ADDRESS and not the RPC_ADDRESS. 213.186.117.170:9160 would be the one you should connect on and not the other which is used for cassandra - cassandra communication.

sdolgy
  • 6,963
  • 3
  • 41
  • 61