Home > front end >  .Net Core app: Unable to connect to Cassandra 1 node server from a remote PC
.Net Core app: Unable to connect to Cassandra 1 node server from a remote PC

Time:12-05

  1. I have 1 node test Cassandra claster (IP 192.168.108.198). In Cassandra.yaml listen_address: localhost.

  2. I can connect to it via DBeaver (using ssh port forwarding ), and work in it.

  3. I wrote .net app for using it, but it cant connect to cassandra: "All hosts tried for query failed (tried 192.168.108.198:9042: SocketException". It happens on the last row, as below. Is it problem with cassandra config or my app?

             _connectionConfig = connectionConfig;
             _socketOptions = new SocketOptions();
             _socketOptions.SetReadTimeoutMillis(90000);
    
                 _cluster = Cluster.Builder()
              .WithPort(_connectionConfig.ConnectionPort)
              .AddContactPoints(_connectionConfig.ConnectionStrings)
              .WithSocketOptions(_socketOptions)
              .WithQueryOptions(new QueryOptions().SetConsistencyLevel(ConsistencyLevel.One))
              .WithAuthProvider(new PlainTextAuthProvider(_connectionConfig.UserName, _connectionConfig.UserPassword))
              .Build();
    
              _session = _cluster.Connect(_connectionConfig.KeySpaceName);
    

enter image description here enter image description here

CodePudding user response:

So, i corrected some settings in Cassandra.yaml, and now connection is going fine, appender other problems, but right settings are:

- class_name: org.apache.cassandra.locator.SimpleSeedProvider
  parameters:
      # seeds is actually a comma-delimited list of addresses.
      # Ex: "<ip1>,<ip2>,<ip3>"
      - seeds: "192.168.108.198"

listen_address: 192.168.108.198
rpc_address: 192.168.108.198

192.168.108.198 - Cassandra IP.

  • Related