【问题标题】:Handshake failed due to an unexpected packet format由于意外的数据包格式,握手失败
【发布时间】: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


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2011-07-07
      • 2021-10-27
      • 1970-01-01
      • 2023-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-15
      相关资源
      最近更新 更多