在 EC2 上使用 c# 控制台应用程序 运行 连接到雪花时出现问题
Issue with connection to snowflake using c# console application running on EC2
我有一个 C# 控制台应用程序,它使用 Snowflake .NET 连接器来连接 Snowflake DB。应用程序在我的系统上运行良好,但是如果我将该应用程序带到 EC2 并执行,则它不会连接到 Showflake DB 并出现错误“SnowflakeDbException:请求达到其超时”。
AWS EC2 实例和 Snowflake 数据库之间的网络连接已到位。
下面是我正在使用的代码:
static void Main(string[] args)
{
try
{
using (IDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = "scheme=https;account=<accountname>;port=443;user=.
<xxxxxx>;password=<xxxxxx>;ROLE=<definedRole>;warehouse=<warehouse>;db=
<DBNAME>;schema=<schemaname>";
conn.Open(); //ERROR: "SnowflakeDbException: Request reach its timeout"
Console.WriteLine("Connection successful!");
using (IDbCommand cmd = conn.CreateCommand())
{
cmd.CommandText = "select * from TABLE1";
//data from an existing table
IDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Console.WriteLine(reader.GetString(0));
}
conn.Close();
}
}
}
catch (DbException exc)
{
Console.WriteLine("Error Message: {0}", exc.Message);
}
}
如果我使用如下所示的 powershell 执行 'Test-NetConnection' 命令,那么它就成功了。
Test-NetConnection -computerName xxxx.eu-west-1.privatelink.snowflakecomputing.com -port 443
结果:TCPTestSucceeded:真
StackTrace Error Image
Trace post enabling Logging
System.Net.Http.HttpRequestException: 发送请求时出错。 ---> System.Net.WebException:底层连接已关闭:
无法为 SSL/TLS 安全通道建立信任关系。 ---> System.Security.Authentication.AuthenticationException:
根据验证程序,远程证书无效。
cURL output
SnowCD output
您未通过 CRL check。设置参数 INSECUREMODE=true 将禁用证书吊销列表检查并且测试应该通过,但不建议在生产系统中这样做。
我有一个 C# 控制台应用程序,它使用 Snowflake .NET 连接器来连接 Snowflake DB。应用程序在我的系统上运行良好,但是如果我将该应用程序带到 EC2 并执行,则它不会连接到 Showflake DB 并出现错误“SnowflakeDbException:请求达到其超时”。
AWS EC2 实例和 Snowflake 数据库之间的网络连接已到位。
下面是我正在使用的代码:
static void Main(string[] args)
{
try
{
using (IDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = "scheme=https;account=<accountname>;port=443;user=.
<xxxxxx>;password=<xxxxxx>;ROLE=<definedRole>;warehouse=<warehouse>;db=
<DBNAME>;schema=<schemaname>";
conn.Open(); //ERROR: "SnowflakeDbException: Request reach its timeout"
Console.WriteLine("Connection successful!");
using (IDbCommand cmd = conn.CreateCommand())
{
cmd.CommandText = "select * from TABLE1";
//data from an existing table
IDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Console.WriteLine(reader.GetString(0));
}
conn.Close();
}
}
}
catch (DbException exc)
{
Console.WriteLine("Error Message: {0}", exc.Message);
}
}
如果我使用如下所示的 powershell 执行 'Test-NetConnection' 命令,那么它就成功了。
Test-NetConnection -computerName xxxx.eu-west-1.privatelink.snowflakecomputing.com -port 443
结果:TCPTestSucceeded:真
StackTrace Error Image
Trace post enabling Logging
System.Net.Http.HttpRequestException: 发送请求时出错。 ---> System.Net.WebException:底层连接已关闭: 无法为 SSL/TLS 安全通道建立信任关系。 ---> System.Security.Authentication.AuthenticationException: 根据验证程序,远程证书无效。
cURL output
SnowCD output
您未通过 CRL check。设置参数 INSECUREMODE=true 将禁用证书吊销列表检查并且测试应该通过,但不建议在生产系统中这样做。