0

So I've been using the MySql.Data from NuGet for a long time for connecting with my MariaDB databases in a lot of different .NET projects. It happens that now I'm starting a new .NET5 project and to start fresh just installed the last version 8.0.26 of the MySql.Data package, but when trying to connect to the database I'm getting the following error:

MySql.Data.MySqlClient.MySqlException HResult=0x80004005 Message=SSL Connection error. Source=MySql.Data StackTrace: at MySql.Data.Common.Ssl.StartSSL(Stream& baseStream, Encoding encoding, String connectionString) at MySql.Data.MySqlClient.NativeDriver.Open() at MySql.Data.MySqlClient.Driver.Open() at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings) at MySql.Data.MySqlClient.MySqlConnection.Open() at MySqlSSLErrorTest.Program.Main(String[] args) in C:\Users\Murillo\source\repos\MySqlSSLErrorTest\MySqlSSLErrorTest\Program.cs:line 16

This exception was originally thrown at this call stack: System.Net.Security.SslStream.ReceiveBlobAsync(TIOAdapter) System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task) System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) System.Threading.Tasks.ValueTask.Result.get() System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable.ConfiguredValueTaskAwaiter.GetResult() System.Net.Security.SslStream.ForceAuthenticationAsync(TIOAdapter, bool, byte[], bool)

Inner Exception 1: AggregateException: One or more errors occurred. (Cannot determine the frame size or a corrupted frame was received.)

Inner Exception 2: IOException: Cannot determine the frame size or a corrupted frame was received.

Now, as I've been searching, it seems that the version 8.0.26 it's comming with some changes as stated here at the MySql website regarding this issue (maybe?), but I haven't been able to understand what exactly are the changes I need to make to my Connection String to make it work.

Here I leave a very simple Console App example to reproduce the error:

class Program
{
    
    static void Main(string[] args)
    { 
        MySqlConnection con = new MySqlConnection("DATABASE=myDB; data source=localhost; user=root; PASSWORD=pass; POOLING=FALSE;");

        con.Open(); //ERROR HERE
    }
}

I'm aware that I can downgrade the package to an older version to make it work, but I would like to understand how to solve this issue in order to be up to date with the latest features.

Thanks!

3
  • 1
    The MariaDB pages point to an alternate .NET connector that appears current. Commented Aug 19, 2021 at 5:51
  • 1
    The TLS changes you linked to are in version 8.0.26 of MySQL Server itself, not the MySql.Data package. I suspect the issue might be with using MySql.Data on .NET 5.0; in my experience it's not as well-tested on .NET Core. I'd suggest trying out nuget.org/packages/MySqlConnector (disclaimer: lead author) in your .NE 5.0 project and seeing if that works better. Commented Aug 19, 2021 at 22:19
  • Thanks Bradley. It's nice to have some feedback from the author. As danblack sugested, I installed MySqlConnector and it worked perfectly as it was with the past versions of MySql.Data. To be honest, I'd never had a problem with MySql.Data until now, but since I'm using mainly MariaDB now and they are slowly starting to diverge from MySQL, I think I'll definetly give a try to MySQLConnector, especially when it seems best suited and even recomended by the MariaDB team aswell. Again, many thanks to you both. Commented Aug 20, 2021 at 5:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.