由于意外的数据包格式,握手失败

Handshake failed due to an unexpected packet format

我正在尝试与 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 添加到我的计算机受信任的根证书中。

感谢任何有关我收到此异常的原因的见解。

原来问题与代码无关。使用 Wireshark 嗅探数据包后,我发现问题出在网络交换机故障丢失数据包上。