【发布时间】:2017-12-25 07:02:06
【问题描述】:
我正在尝试与托管在 Amazon Web Services 上的 MySQL 数据库建立稳定的连接。定期启动应用程序时,我会收到异常:
由于意外的数据包格式,握手失败
这是一个使用 MySQL.Data.dll V6.9.9 的 WinForm C# 应用程序
这是我的连接代码:
using (var conn = new MySqlConnection(m_connectionString))
{
try
{
conn.Open();
Console.WriteLine("Connected to database");
}
catch (MySqlException ex)
{
validConnectionFound = false;
Console.WriteLine(ex);
MessageBox.Show("Unable to connect to Database. Check your network connection and try again", "Database connection Not Found");
}
catch (CryptographicException ex)
{
validConnectionFound = false;
MessageBox.Show("Cryptographic Exception: " + ex.Message);
Environment.Exit(0);
}
catch(IOException ex)
{
validConnectionFound = false;
DebugTrace.TraceWrite(m_defaultTraceSource, TraceEventType.Error, "Incorrect certificate. Please update security certificate. Exception: " + ex.Message);
MessageBox.Show("IO Exception: " + ex.Message);
Environment.Exit(0);
}
}
我的连接字符串格式如下:
"user id=user;password=1234;server=amazonserver.com;database=myDatabase;convertzerodatetime=True;port=3306;sslmode=VerifyCA"
我尝试了无线和有线连接,更改了所需的 SSL 模式(VerifyCA、Required、VerifyFull、None),并将 Amazons CA 添加到我的计算机受信任的根证书中。
感谢任何关于我为什么会收到此异常的见解。
【问题讨论】:
标签: c# mysql amazon-rds