I DID respond with more details.
.NET -> MySql random connection issues
Random, and rarely, our .NET app running on Azure gets connection errors as follows.
We're running MySql 5.7 ( yes, we know ... )
FYI, the app has almost no error handling, and no logging.
We inherited this app.
Here is the error returned from Application Insights, as stated all errors seem to be from READs:
Fatal error encountered during command execution. Fatal error encountered attempting to read the resultset. Reading from the stream has failed. Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.. A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
The data access for the entire app is THE most basic.
Razor pages with embedded SQL, and here is the entire DA code:
using Dapper;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataLibrary
{
public class DataAccess : IDataAccess
{
public async Task<List<T>> LoadData<T, U>(string sql, U parameters, string connectionString)
{
using (IDbConnection connection = new MySqlConnection(connectionString))
{
var results = await connection.QueryAsync<T>(sql, parameters);
return results.ToList();
}
}
public Task SaveData<T>(string sql, T parameters, string connectionString)
{
using (IDbConnection connection = new MySqlConnection(connectionString))
{
return connection.ExecuteAsync(sql, parameters);
}
}
}
}
Azure Database for MySQL
-
Deleted
This comment has been deleted due to a violation of our Code of Conduct. The comment was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
-
Adithya Prasad K • 90 Reputation points • Microsoft External Staff
2025-02-20T13:50:49.1366667+00:00 Hi bob housedorf,
Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.Could you please confirm whether you are facing an issue with the .NET application or the Azure MySQL database?
If possible, additional information would be greatly appreciated, as it will help us conduct a more thorough investigation. Thank you!"
-
bob housedorf • 0 Reputation points
2025-02-21T00:29:51.6166667+00:00 I don't think the problem is with either.
if i dig enough, the problem usually seems to be on a sql MoveNext
It's not a cpu issue with either the web app or MySql.
BOTH are running in Azure.
We don't see excess user connections.
I'm just seriously wondering if it is simply because MySql was never updated by the previous devs.
I am NOT a MySql type of guy.There are no errors in MySql logs.
Healthcheck shows no problems for MySql.
The exception is: System.Net.Sockets.SocketException
Failed method: MySql.Data.MySqlClient.TimedStream.Read
FormattedMessage: Unhandled exception in circuit 'I3uIcuXVFI62aVLbmF_m2Vq9K-lBhtIJBMvbrSnjnC4'.call stack
MySql.Data.MySqlClient.MySqlException:at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader (MySql.Data, Version=8.0.30.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteDbDataReader (MySql.Data, Version=8.0.30.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d)
at System.Data.Common.DbCommand.ExecuteReader (System.Data.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Data.Common.DbCommand.ExecuteDbDataReaderAsync (System.Data.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Dapper.SqlMapper+<QueryAsync>d__33`1.MoveNext (Dapper, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null: /_/Dapper/SqlMapper.Async.cs:418)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at DataLibrary.DataAccess+<LoadData>d__0`2.MoveNext (DataLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: E:\Personal\Website-20231004T181348Z-001\Website\LESSystemBlazor - Copy\LESSystemBlazor\DataLibrary\DataAccess.cs:18)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at LESSystemBlazor.Pages.NewBilling+<RowSelectHandler>d__35.MoveNext (LESSystemBlazor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: E:\Personal\Website-20231004T181348Z-001\Website\LESSystemBlazor - Copy\LESSystemBlazor\LESSystemBlazor\Pages\NewBilling.razor:406)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.AspNetCore.Components.ComponentBase+<CallStateHasChangedOnAsyncCompletion>d__22.MoveNext (Microsoft.AspNetCore.Components, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Syncfusion.Blazor.Grids.Internal.Selection`1+<SelectByRow>d__33.MoveNext (Syncfusion.Blazor, Version=20.2.0.45, Culture=neutral, PublicKeyToken=null)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Syncfusion.Blazor.Grids.Internal.Selection`1+<ValidateRowSelectionClick>d__40.MoveNext (Syncfusion.Blazor, Version=20.2.0.45, Culture=neutral, PublicKeyToken=null)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Syncfusion.Blazor.Grids.Internal.Selection`1+<RowSelectionClickHandler>d__39.MoveNext (Syncfusion.Blazor, Version=20.2.0.45, Culture=neutral, PublicKeyToken=null)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Syncfusion.Blazor.Grids.Internal.Selection`1+<ClickHandler>d__35.MoveNext (Syncfusion.Blazor, Version=20.2.0.45, Culture=neutral, PublicKeyToken=null)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Syncfusion.Blazor.Grids.Internal.GridCellBase`1+<CellClickHandler>d__80.MoveNext (Syncfusion.Blazor, Version=20.2.0.45, Culture=neutral, PublicKeyToken=null)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Syncfusion.Blazor.Grids.Internal.GridCell`1+<<BuildRenderTree>b__0_5>d.MoveNext (Syncfusion.Blazor, Version=20.2.0.45, Culture=neutral, PublicKeyToken=null)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.AspNetCore.Components.ComponentBase+<CallStateHasChangedOnAsyncCompletion>d__22.MoveNext (Microsoft.AspNetCore.Components, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.AspNetCore.Components.RenderTree.Renderer+<GetErrorHandledTask>d__66.MoveNext (Microsoft.AspNetCore.Components, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
Inner exception MySql.Data.MySqlClient.MySqlException handled at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader:
at MySql.Data.MySqlClient.MySqlDataReader.NextResult (MySql.Data, Version=8.0.30.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader (MySql.Data, Version=8.0.30.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d)
Inner exception MySql.Data.MySqlClient.MySqlException handled at MySql.Data.MySqlClient.MySqlDataReader.NextResult:
at MySql.Data.MySqlClient.MySqlStream.LoadPacket (MySql.Data, Version=8.0.30.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d)
at MySql.Data.MySqlClient.MySqlStream.ReadPacket (MySql.Data, Version=8.0.30.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d)
at MySql.Data.MySqlClient.NativeDriver.GetResult (MySql.Data, Version=8.0.30.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d)
at MySql.Data.MySqlClient.Driver.GetResult (MySql.Data, Version=8.0.30.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d)
at MySql.Data.MySqlClient.Driver.NextResult (MySql.Data, Version=8.0.30.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d)
at MySql.Data.MySqlClient.MySqlDataReader.NextResult (MySql.Data, Version=8.0.30.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d)
Inner exception System.IO.IOException handled at MySql.Data.MySqlClient.MySqlStream.LoadPacket:
at System.Net.Sockets.NetworkStream.Read (System.Net.Sockets, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Net.Security.SslStream+<EnsureFullTlsFrameAsync>d__186`1.MoveNext (System.Net.Security, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Net.Security.SslStream+<ReadAsyncInternal>d__188`1.MoveNext (System.Net.Security, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Net.Security.SslStream.Read (System.Net.Security, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at MySql.Data.MySqlClient.TimedStream.Read (MySql.Data, Version=8.0.30.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d)
at MySql.Data.MySqlClient.MySqlStream.ReadFully (MySql.Data, Version=8.0.30.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d)
at MySql.Data.MySqlClient.MySqlStream.LoadPacket (MySql.Data, Version=8.0.30.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d)
Inner exception System.Net.Sockets.SocketException handled at System.Net.Sockets.NetworkStream.Read:
at System.Net.Sockets.NetworkStream.Read (System.Net.Sockets, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
-
Adithya Prasad K • 90 Reputation points • Microsoft External Staff
2025-02-21T08:28:11.89+00:00 Hi bob housedorf,
We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet. In case if you have any resolution please do share that same with the community as it can be helpful to others. Otherwise, will respond with more details and we will try to help.
-
Adithya Prasad K • 90 Reputation points • Microsoft External Staff
2025-02-24T12:54:08.1266667+00:00 Hi bob housedorf,
Based on your inquiry, we understand that the exception you're encountering, specificallySystem.Net.Sockets.SocketException
during aMoveNext
operation in a MySQL command, suggests that there may be issues with the network connection between your .NET application and the MySQL database hosted on Azure.I would request you to refer the below mentioned links for more information
https://learn.microsoft.com/en-us/azure/mysql/
https://learn.microsoft.com/en-us/azure/static-web-apps/database-mysql?tabs=bash&pivots=static-web-apps-rest
I hope this information helps. Please do let us know if you have any further queries. -
bob housedorf • 0 Reputation points
2025-02-24T18:26:22.34+00:00 Just FYI, that reply was in way useful.
I ALREADY KNOW there is a network connection issue.WHY / HOW is there a networking issue from an Azure Web App to an Azure MySql instance?
WHERE do I go in Azure to figure this out?In a .NET Web App, is there someplace to examine connection pooling?
-
Adithya Prasad K • 90 Reputation points • Microsoft External Staff
2025-02-25T10:55:31.4966667+00:00 To troubleshoot networking issues between an Azure Web App and an Azure MySQL instance, start by checking the connection strings and firewall settings. Ensure that the MySQL server allows connections from the Web App's outbound IP addresses and verify that the Web App's configuration is set up correctly for the database connection.
-
Adithya Prasad K • 90 Reputation points • Microsoft External Staff
2025-02-26T08:51:49.4733333+00:00 Hi bob housedorf
We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet. In case if you have any resolution please do share that same with the community as it can be helpful to others. Otherwise, will respond with more details and we will try to help. -
Deleted
This comment has been deleted due to a violation of our Code of Conduct. The comment was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
Sign in to comment
1 answer
Sort by: Most helpful
-
bob housedorf • 0 Reputation points
2025-02-21T20:08:52.93+00:00