Bug #116146 OpenAsync (of MySqlConnection) throws exception when UseCompression = true
Submitted: 18 Sep 13:16
Reporter: Yitzhak Shmuel Email Updates:
Status: Open Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:9.0.0 OS:Windows (Windows 10 Enterprise)
Assigned to: Reggie Burnett CPU Architecture:Any

[18 Sep 13:16] Yitzhak Shmuel
Description:
Hi,

When calling the OpenAsync method of MySqlConnection, when the UseCompression of MySqlConnectionStringBuilder is set to true, a "EndOfStreamException: Attempted to read past the end of the stream" exception is thrown.

Using the Open method instead of the OpenAsync method works as expected.
Also, setting the UseCompression to false works as expected as well.

I'm using VS2022, dotnet 8, MySql.Data nuget package, version 9.0.0.

Thanks

How to repeat:
using MySql.Data.MySqlClient;

internal class Program
{
    private static async Task<int> Main(string[] args)
    {        
        var cancellationToken = new CancellationToken();
        var mySqlConnectionStringBuilder = new MySqlConnectionStringBuilder
        {          
            UserID = "userid", Password = "pass", Server = "server", Port = 3306, Database = "db",
            UseCompression = true
        };

        await using (var dbConnection = new MySqlConnection(mySqlConnectionStringBuilder.ConnectionString))
        {
            await dbConnection.OpenAsync(cancellationToken);
            await using (MySqlCommand queryCommand = new MySqlCommand("SELECT 1", dbConnection))
            {
                var res = await queryCommand.ExecuteNonQueryAsync(cancellationToken);
            }
        }

        return 0;
    }
}