MySqlConnector: MySql.Data.MySqlClient.MySqlException (0x80004005): Connect Timeout expired
I have this problem several months and i can’t find the reason why this is happens. When i have high load on my website, connections to database from .net core increases to max value of my connection string (maximumpoolsize=100). And after that i receive multiple Connect timeouts. In meanwhile database is free, without locks, queries from another systems executes immediately (less than a second). So my connection pool is full, queries to database is not executed and database in this time works well. It seems that system can’t get connection from pool because old connections are hang. What can it be? Please help me.
MySql.Data.MySqlClient.MySqlException (0x80004005): Connect Timeout expired. ---> System.OperationCanceledException: The operation was canceled.
Apr 18 10:33:00 web portal[962]: at System.Threading.CancellationToken.ThrowOperationCanceledException()
Apr 18 10:33:00 web portal[962]: at System.Threading.SemaphoreSlim.<WaitUntilCountOrTimeoutAsync>d__32.MoveNext()
Apr 18 10:33:00 web portal[962]: --- End of stack trace from previous location where exception was thrown ---
Apr 18 10:33:00 web portal[962]: at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Apr 18 10:33:00 web portal[962]: at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
Apr 18 10:33:00 web portal[962]: at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Apr 18 10:33:00 web portal[962]: at System.Threading.SemaphoreSlim.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
Apr 18 10:33:00 web portal[962]: at MySqlConnector.Core.ConnectionPool.<GetSessionAsync>d__0.MoveNext() in C:\projects\mysqlconnector\src\MySqlConnector\Core\ConnectionPool.cs:line 30
Apr 18 10:33:00 web portal[962]: --- End of stack trace from previous location where exception was thrown ---
Apr 18 10:33:00 web portal[962]: at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Apr 18 10:33:00 web portal[962]: at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
Apr 18 10:33:00 web portal[962]: at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Apr 18 10:33:00 web portal[962]: at MySql.Data.MySqlClient.MySqlConnection.<CreateSessionAsync>d__77.MoveNext() in C:\projects\mysqlconnector\src\MySqlConnector\MySql.Data.MySqlClient\MySqlConnection.cs:line 355
Apr 18 10:33:00 web portal[962]: at MySql.Data.MySqlClient.MySqlConnection.<CreateSessionAsync>d__77.MoveNext() in C:\projects\mysqlconnector\src\MySqlConnector\MySql.Data.MySqlClient\MySqlConnection.cs:line 370
Apr 18 10:33:00 web portal[962]: --- End of stack trace from previous location where exception was thrown ---
Apr 18 10:33:00 web portal[962]: at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Apr 18 10:33:00 web portal[962]: at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Apr 18 10:33:00 web portal[962]: at MySql.Data.MySqlClient.MySqlConnection.<OpenAsync>d__19.MoveNext() in C:\projects\mysqlconnector\src\MySqlConnector\MySql.Data.MySqlClient\MySqlConnection.cs:line 160
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15 (5 by maintainers)
I use 0.32 version from Pomelo.EntityFrameworkCore.MySql latest package. I will change to latest MySqlConnector 0.40.1 and give it a try. I have sometimes more than 100 simultaneous requests to my Nginx reverse proxy. I register Entity framework context as default dependency injection and inject it in my MVC Controller’s constructor. I don’t dispose it manually.