Problem connecting to a Cassandra Cluster

695 views
Skip to first unread message

Evangelos Karvounis

unread,
Apr 5, 2016, 10:28:14 AM4/5/16
to DataStax PHP Driver for Apache Cassandra User Mailing List
Hello dear friends,

I am currently involved in creating an API that uses a Cassandra cluster for storing data. I was developing it on my local machine using PHP 5.6.17, Cassandra 2.2.3 and the Datastax PHP Driver 1.1.0 and everything went fine. However, we decided to move to a remote Cassandra cluster and I cannot access it through PHP as I get the following error: An error occured: 16777226 - No hosts available for the control connection.
The funny thing is that using the remote cluster's ip and using the DevCenter, I managed to connect to that cluster, create a new keyspace and also a table inside the new keyspace.
The error producing PHP code is the following:

$cluster = \Cassandra::cluster()->withContactPoints('x.x.x.x')->build();
$keyspace = 'foo';
$session = $cluster->connect($keyspace);

The last line is the one producing the error. However, if I try to connect to the local cassandra cluster using $cluster = \Cassandra::cluster()->build(); then it works like a charm.
Does anybody have any idea why this is happening?

Cheers,
Evangelos

Michael Fero

unread,
Apr 5, 2016, 10:35:02 AM4/5/16
to php-dri...@lists.datastax.com
Hello Evangelos,

Does the keyspace `foo` exist? It sounds like you might be running into the following bug in the C/C++ driver which is a PHP driver dependency: https://datastax-oss.atlassian.net/browse/CPP-281.

~Fero

Message has been deleted

Evangelos Karvounis

unread,
Apr 5, 2016, 11:49:33 AM4/5/16
to DataStax PHP Driver for Apache Cassandra User Mailing List
It actually exists and there is at least one row of data inside that keyspace->table.

Michael Fero

unread,
Apr 6, 2016, 6:47:47 AM4/6/16
to DataStax PHP Driver for Apache Cassandra User Mailing List
Evangelos,

Would it be possible for you to upgrade the underlying C/C++ driver that the PHP driver utilizes to confirm the issue still exists; a keyspace error is now emitted when establishing a session connection to a keyspace https://github.com/datastax/cpp-driver/blob/2.3.0/src/connection.cpp#L83-L86. I understand you indicated that the keyspace exists, but it may be possible that one of the nodes didn't know about the keyspace during the connection attempt (just theorizing).

If you are unable to upgrade the C/C++ driver utilized by the PHP driver then as a workaround I would recommend creating a session object without supplying the keyspace and using fully qualified naming in your queries (e.g. keyspace.tablename).

~Fero

Evangelos Karvounis

unread,
Apr 6, 2016, 6:54:54 AM4/6/16
to DataStax PHP Driver for Apache Cassandra User Mailing List
I think the problem is that I am trying to connect to a remote Cassandra cluster 3.0.4. I found somewhere that the current version of php-driver is not compatible with Cassandra 3.x. Is there any indication on when the php-driver is going to be compatible?

Michael Fero

unread,
Apr 6, 2016, 7:23:43 AM4/6/16
to DataStax PHP Driver for Apache Cassandra User Mailing List
The PHP driver works with Cassandra v2.2+; however it does not allow you to use all the features present in these versions of Cassandra. The current PHP driver, v1.1.0, exposes all features available up to Cassandra v2.1.x. The C/C++ driver dependency recently added full feature support for Cassandra v3.0+ in v2.3.0 and will soon be added into the PHP driver. The next release version has not been fully formed yet, but status can be tracked here https://datastax-oss.atlassian.net/browse/PHP.

Evangelos Karvounis

unread,
Apr 6, 2016, 7:35:34 AM4/6/16
to DataStax PHP Driver for Apache Cassandra User Mailing List
So, the only option right now to connect to Cassandra 3.x using the php-driver, is to wait until they release a new version of the php-driver. I have installed Cassandra 3.4 on my machine as well, created a keyspace, a table, added a few rows of data but the php script cannot still connect to it producing the same error:

An error occured: 16777226 - No hosts available for the control connection

Thank you Michael for your replies.

Manoj Kumar

unread,
Jan 31, 2018, 8:38:48 AM1/31/18
to DataStax PHP Driver for Apache Cassandra User Mailing List

hi is the problem of connecting to remote machine is solved ? what is the current version i need to use using the php-driver.

Michael Fero

unread,
Jan 31, 2018, 8:54:29 AM1/31/18
to DataStax PHP Driver for Apache Cassandra User Mailing List
Manoj,

The current PHP driver/extension is v1.3.2 and works with Apache Cassandra versions 2.1, 2.2 and 3.0+ for PHP v5.6, 7.0, and 7.1 (32bit, 64-bit, NTS, and TS). The current version of the C/C++ driver (underlying dependency) is v2.8.0. You may either build your own versions of these drivers using the source available on GitHub (https://github.com/datastax/cpp-driver and https://github.com/datastax/php-driver) or download the pre-built binaries using http://downloads.datastax.com/

~Fero
Michael Fero

Manoj Kumar

unread,
Feb 1, 2018, 1:45:18 AM2/1/18
to DataStax PHP Driver for Apache Cassandra User Mailing List

hi thank you for the reply.

i have installed scylla.2.0.2
cqlsh 5.0.1 | Cassandra 3.0.8 | CQL spec 3.3.1 | Native protocol v4

in a remote Google Cloud Instance

php 7.0 & php-driver 1.3 - in my local machine

when trying to run php file
$cluster = Cassandra::cluster()->withContactPoints('x.x.x.x')->withPort(9042)->build();

Michael Fero

unread,
Feb 1, 2018, 9:31:11 AM2/1/18
to DataStax PHP Driver for Apache Cassandra User Mailing List
Manoj,

We do not test the driver against ScyllaDB; however since they implement the native protocol there shouldn't be an issue connecting to their server instances using the driver. To ensure your configuration is correct you should try connecting to a local Apache Cassandra instance first and then check the driver logs and SycllaDB logs to determine the root cause.

Good luck.

~Fero
Michael Fero

Reply all
Reply to author
Forward
0 new messages