简体   繁体   中英

C# to Cassandra service with username and password

Cassandra is running as a service on a remote machine but in the same network. Also I created a .net program that communicates with the Cassandra environment.

I was able to communicate with Cassandra when it was NOT running as a service with the following connection string:

private void Connect()
    {
        cluster = Cluster.Builder().WithCredentials(username, password).AddContactPoint("192.168.30.104").Build();
        session = cluster.Connect("core_meter");
    }

But when I try to connect to Cassandra when its running as a service I get the following error:

An unhandled exception of type 'Cassandra.NoHostAvailableException' occurred in Cassandra.dll

Additional information: None of the hosts tried for query are available (tried: 192.168.30.104:9042)

I am not sure if I have to change anything in my .yaml file before I can approach a service with username and password. here is the yaml file: https://www.dropbox.com/s/wbrexlarkjrvlrm/cassandra.yaml?dl=0

edit: When i communicate with the service WITHOUT a username and password I can communicate with the service (I can always communicate with the execution through command prompt) but when I use a username and password it does not work anymore.

It seems to me that your service and the single executable are using different yaml configuration files. Check your environment variables and your cassandra-env.sh files. Also have a look at DataStax documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM