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
~Fero
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
Thank you Michael for your replies.
hi is the problem of connecting to remote machine is solved ? what is the current version i need to use using the php-driver.
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
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();
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