简体   繁体   English

连接到 AWS Managed Cassandra Service (MCS)

[英]Connecting to AWS Managed Cassandra Service (MCS)

I have recently started using AWS's Cassandra Managed Service offering, and am trying to programmatically connect to the sample keytable AWS shows in their documentation.我最近开始使用 AWS 的 Cassandra Managed Service 产品,并尝试以编程方式连接到 AWS 在其文档中显示的示例密钥表。 I've downloaded the Cassandra c# driver and gotten the generated service credentials.我已经下载了 Cassandra c# 驱动程序并获得了生成的服务凭证。 The trouble I am having right now is connecting to the cluster (cluster.Connect()).我现在遇到的问题是连接到集群 (cluster.Connect())。 I have tried using a variety of different cluster names in .Connect without luck.我尝试在 .Connect 中使用各种不同的集群名称,但没有运气。 Anyone know that the cluster name should be, or where to find it?任何人都知道集群名称应该是什么,或者在哪里可以找到它? Also, is there something else I don't have?另外,还有什么我没有的吗? Does this need TLS connection programming to work?这是否需要 TLS 连接编程才能工作?

The error I'm receiving is 'Host not found':我收到的错误是“找不到主机”:

using System;
using Cassandra;

namespace SampleConnect
{
    class Program
    {
        static void Main(string[] args)
        {
            var cluster = Cluster.Builder()
                                 .AddContactPoints("cassandra.us-east-2.amazonaws.com")
                                 .WithPort(9142)
                                 //.WithLoadBalancingPolicy(new DCAwareRoundRobinPolicy("AWS_VPC_AP_SOUTHEAST_2"))
                                 .WithAuthProvider(new PlainTextAuthProvider("credential username", "crededential password"))
                                 .Build();

            // Connect to the nodes using a keyspace
            var session = cluster.Connect();

            // Get name of a Cluster
            Console.WriteLine("The cluster's name is: " + cluster.Metadata.ClusterName);

            // Execute a query on a connection synchronously
            var rs = session.Execute("SELECT * FROM tutorialtable");

            // Iterate through the RowSet
            foreach (var row in rs)
            {
                var value = row.GetValue<string>("keyspace_name");
                Console.WriteLine(value);
                // Do something with the value
            }
        }
    }
}

Error Message:错误信息:

All hosts tried for query failed (tried 3.17.137.4:9042: SocketException 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.')所有主机尝试查询失败(尝试 3.17.137.4:9042: SocketException '连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立连接失败,因为连接的主机未能响应。')

Stack Trace:堆栈跟踪:

   at Cassandra.Connections.ControlConnection.<Connect>d__39.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
   at Cassandra.Connections.ControlConnection.<InitAsync>d__36.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
   at Cassandra.Tasks.TaskHelper.<WaitToCompleteAsync>d__10.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Cassandra.Cluster.<Cassandra-SessionManagement-IInternalCluster-OnInitializeAsync>d__50.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at Cassandra.ClusterLifecycleManager.<InitializeAsync>d__3.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
   at Cassandra.Cluster.<Cassandra-SessionManagement-IInternalCluster-ConnectAsync>d__47`1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at Cassandra.Cluster.<ConnectAsync>d__46.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Cassandra.Tasks.TaskHelper.WaitToComplete(Task task, Int32 timeout)
   at Cassandra.Tasks.TaskHelper.WaitToComplete[T](Task`1 task, Int32 timeout)
   at Cassandra.Cluster.Connect(String keyspace)
   at Cassandra.Cluster.Connect()
   at LoadBusinessData.Program.Main(String[] args) in Program.cs:line 20 

You need to use SSL/TLS.您需要使用 SSL/TLS。 So your instincts on that are correct.所以你的直觉是正确的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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