I have created a single node ScyllaDB in docker, which is up and running, and below is my docker-compose commands: version: "3"
services:
scylla-node1:
container_name: scylla-node1
image: scylladb/scylla
restart: always
command: --smp 2 --memory 1500M --broadcast-rpc-address 127.0.0.1 --listen-address 0.0.0.0
ports:
- 9042:9050
networks:
web:
networks:
web:
driver: bridge
Reading the documentation for Scylla it recommends using the DataStax C# Driver for Apache Cassandra. So, I have used this in my solution. Following the basic examples, I am struggling to get it work. Thus,
var cluster = Cluster.Builder()
.AddContactPoints("0.0.0.0")
.Build();
var session = cluster.Connect("sample_keyspace");
When the code reaches the Connect command it throws the following error Cassandra.NoHostAvailableException: 'All hosts tried for query failed (tried 0.0.0.0:9042: SocketException 'The requested address is not valid in its context.')'
Firstly, I can connect to Scylla through the CSQL Utility and can create a Keyspace and then run a query to confirm that the Keyspace has been created.
Is this a problem with C# Driver or am I doing something wrong?
This looks like a networking issue to me because your Docker container doesn't appear to be configured correctly.
The problem is that the C# driver (your application) is not able to connect to the container because there is no network connectivity. That is what this exception means:
I assume "CSQL utility" is a typo. The reason you are able to connect using cqlsh is because you are most likely connecting with:
which isn't the same as connecting remotely. To be fair I'm making an assumption as you didn't provide details.
You've configured the container with
--broadcast-rpc-address 127.0.0.1so it will only listen for client connections onlocalhost. This means that you can't use0.0.0.0as the contact point.I've also noted that you've mapped the container port
9050to host port9042:By default, Cassandra listens for client connections on port
9042, not9050. If nothing is listening on port9050, there's nothing for the driver to connect to and will also lead toNoHostAvailableException. Cheers!