[英]Issue with connection to snowflake using c# console application running on EC2
I have a C# console application which is using Snowflake .NET connector to connect with Snowflake DB.我有一个 C# 控制台应用程序,它使用 Snowflake .NET 连接器连接 Snowflake DB。 Application is working fine on my system however if I take that application to EC2 and execute then it's not connecting to Showflake DB with giving error "SnowflakeDbException: Request reach its timeout".应用程序在我的系统上运行良好,但是如果我将该应用程序带到 EC2 并执行,则它不会连接到 Showflake DB,并给出错误“SnowflakeDbException:请求达到超时”。
Network connectivity between AWS EC2 instance and Snowflake DB is in place. AWS EC2 实例和 Snowflake DB 之间的网络连接就位。
Below is the code that I'm using:下面是我正在使用的代码:
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);
}
}
If I do 'Test-NetConnection' command using powershell as below then it is succeeded.如果我使用 powershell 执行“Test-NetConnection”命令,如下所示,那么它就成功了。
Test-NetConnection -computerName xxxx.eu-west-1.privatelink.snowflakecomputing.com -port 443
Result: TCPTestSucceeded : True结果:TCPTestSucceeded:真
StackTrace Error Image StackTrace 错误图像
Trace post enabling Logging跟踪帖子启用日志记录
System.Net.Http.HttpRequestException: An error occurred while sending the request. System.Net.Http.HttpRequestException:发送请求时出错。 ---> System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. ---> System.Net.WebException: 底层连接已关闭:无法为 SSL/TLS 安全通道建立信任关系。 ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure. ---> System.Security.Authentication.AuthenticationException: 根据验证程序,远程证书无效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.