Skip to content

Connecting to Azure MySQL fails #259

Closed
@bgrainger

Description

@bgrainger

Create an Azure MySQL 5.7 instance and attempt to connect to it.

A NullReferenceException is thrown:

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at MySql.Data.MySqlClient.MySqlConnection.CloseDatabase()
   at MySql.Data.MySqlClient.MySqlConnection.DoClose()
   at MySql.Data.MySqlClient.MySqlConnection.Dispose(Boolean disposing)
   at System.ComponentModel.Component.Dispose()
   at Program.<DoStuffAsync>d__1.MoveNext() in C:\Program.cs:line 10

After fixing this bug in CloseDatabase, we get the underlying exception:

Unhandled Exception: System.FormatException: Expected to read 0x00 but got 0xFE
   at MySql.Data.ByteArrayReader.ReadByte(Byte value)
   at MySql.Data.Serialization.OkPayload.Create(PayloadData payload)
   at MySql.Data.Serialization.MySqlSession.<ConnectAsync>d__48.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
   at MySql.Data.MySqlClient.ConnectionPool.<GetSessionAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at MySql.Data.MySqlClient.MySqlConnection.<CreateSessionAsync>d__66.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at MySql.Data.MySqlClient.MySqlConnection.<OpenAsync>d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at MySql.Data.MySqlClient.MySqlConnection.Open()

When connecting, we are expecting to get an OK packet, but the server is sending a change authentication packet instead.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions