Bug #88508 Error on first connection using MySQL .Net Connector 6.9.9 or higher version
Submitted: 15 Nov 2017 22:42 Modified: 16 Nov 2017 21:07
Reporter: Venkata Sanmukheswar Rao Pachipenta Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:6.9.9 OS:Windows
Assigned to: CPU Architecture:Any
Tags: .net Connector

[15 Nov 2017 22:42] Venkata Sanmukheswar Rao Pachipenta
Description:
I am using ASP.Net application to connect to MySQL database.  I am using C# to develop my web pages and using .Net Connector version 6.9.9.  

This issue happening only on my Production environment.  After application pool recycle, first connection to my database is failing with following error.  I verified other bugs with same error but none of them are similar to my error.  As I mentioned first connection for a given connection string fails after application pool recycle.  Subsequent connections work fine.

I tried the Ping method.  It didn't resolve issue.

Current revering the client back to 6.4.3 to resolved issue.  But we want to use latest version of client libraries.

Exception details:

MySql.Data.MySqlClient.MySqlException (0x80004005): Authentication to host 'PCMUXDS0003N001' for user 'coadminauto' using method 'mysql_native_password' failed with message: Reading from the stream has failed. ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Reading from the stream has failed. ---> System.IO.EndOfStreamException: Attempted to read past the end of the stream.
   at MySql.Data.MySqlClient.MySqlStream.ReadFully(Stream stream, Byte[] buffer, Int32 offset, Int32 count)
   at MySql.Data.MySqlClient.MySqlStream.LoadPacket()
   at MySql.Data.MySqlClient.MySqlStream.LoadPacket()
   at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
   at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.ReadPacket()
   at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.AuthenticationFailed(Exception ex)
   at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.ReadPacket()
   at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.Authenticate(Boolean reset)
   at MySql.Data.MySqlClient.NativeDriver.Open()
   at MySql.Data.MySqlClient.Driver.Open()
   at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
   at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
   at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
   at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
   at MySql.Data.MySqlClient.MySqlPool.GetConnection()
   at MySql.Data.MySqlClient.MySqlConnection.Open()
   at RusticiSoftware.ScormContentPlayer.DataHelp.DataHelper.CreateCommand(String statement)
   at RusticiSoftware.ScormContentPlayer.DataHelp.DataHelper.Execute(String sql, ArrayList parameters, Func`2 result, Func`2 modifySql)
   at RusticiSoftware.ScormContentPlayer.DataHelp.DataHelper.ExecuteSQLReturnDbRows(String sql, ArrayList parameters, Int32 pageSize, Int32 pageNum)
   at RusticiSoftware.ScormContentPlayer.DataHelp.DataHelper.ExecuteSQLReturnDbRows(String sql, ArrayList parameters)
   at RusticiSoftware.ScormContentPlayer.Logic.DataAccess.LoggingDataHelperWrapper.ExecuteSQLReturnDbRows(String sql, ArrayList parameters)
   at RusticiSoftware.ScormContentPlayer.Logic.DataAccess.Schema.Discovery.MySqlSchemaDiscovererImplementation.GetTableNames()
   at RusticiSoftware.ScormContentPlayer.Logic.DataAccess.Schema.Discovery.SchemaDiscoverer.Discover(Boolean filterUnrecognizedTables)
   at RusticiSoftware.ScormContentPlayer.Logic.Upgrade.SchemaUpgradeEnvironment.LoadActualSchema()
   at RusticiSoftware.ScormContentPlayer.Logic.Upgrade.SchemaUpgradeEnvironment.get_ActualSchema()
   at RusticiSoftware.ScormContentPlayer.Logic.Upgrade.Phases.CreateMissingTablesPhase.Execute(UpgradeFacilities facilities)
   at RusticiSoftware.ScormContentPlayer.Logic.Upgrade.UpgradeExecutor.Execute(UpgradeFacilities facilities)

How to repeat:
try
            {
                using (MySqlConnection conn = new MySqlConnection(strSystemConnectionString))
                {
                    if (!conn.Ping())
                    {
                        conn.Open();
                    }
                    using (MySqlCommand cmd = new MySqlCommand("SELECT 1 FROM EngineTenant WHERE 1<>1", conn))
                    {
                        cmd.ExecuteNonQuery();
                    }
                }
            }
[16 Nov 2017 12:31] Chiranjeevi Battula
Hello Venkata,

Thank you for the bug report.
I could not repeat the issue at our end using with Visual Studio 2015, MySQL 5.7.20 and Connector/NET 6.10.4 version.

Thanks,
Chiranjeevi.
[16 Nov 2017 16:17] Venkata Sanmukheswar Rao Pachipenta
I expect that you may not be able to replicate the issue.  Even I am not able to replicate this issue locally in my development environment and happening only in our Production Environment.

Can you please explain the scenarios that can lead to this exception.  As I mentioned, in the same environment using 6.4.3 client we are not getting this exception.  But while using 6.9.9 client, we are getting this error.  

Given this information, you might be able to quickly identify identify area that can result in this exception and changed between 6.4.3 and later versions.
[16 Nov 2017 20:27] Bradley Grainger
The comment "[27 Oct 10:27] Rui Fan" at Bug #76597 claims to have found a solution for this problem: http://blog.csdn.net/fancyf/article/details/78295964
[16 Nov 2017 21:07] Venkata Sanmukheswar Rao Pachipenta
Thank you Bradley.  Solutions provided in the link resolved our issue.

I am marking this bug as closed.