© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
11 replies
SoFt

Weirdest problem - catch doesnt work

try
{
    using (var connection = new MySqlConnection("Server=x;Port=3306;Database=x;Uid=x;Pwd=x;Pooling=true"))
    {
        await connection.OpenAsync();
    }
}
catch(Exception ex)
{
    var q2 = "";
}
try
{
    using (var connection = new MySqlConnection("Server=x;Port=3306;Database=x;Uid=x;Pwd=x;Pooling=true"))
    {
        await connection.OpenAsync();
    }
}
catch(Exception ex)
{
    var q2 = "";
}



x is actually my server's info
If my server is running, this works ok. But if I reboot my server, this code throws unhandled exception! Basically catch doesnt work!

```System.AggregateException
  HResult=0x80131500
  Message=One or more errors occurred. (Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.)
  Source=System.Private.CoreLib
  StackTrace:
   at System.Threading.CancellationTokenSource.ExecuteCallbackHandlers(Boolean throwOnFirstException) in /_/src/libraries/System.Private.CoreLib/src/System/Threading/CancellationTokenSource.cs:line 831
   at System.Threading.TimerQueueTimer.Fire(Boolean isThreadPool) in /_/src/libraries/System.Private.CoreLib/src/System/Threading/Timer.cs:line 683
   at System.Threading.TimerQueue.FireNextTimers() in /_/src/libraries/System.Private.CoreLib/src/System/Threading/Timer.cs:line 331
   at System.Threading.ThreadPoolWorkQueue.Dispatch() in /_/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs:line 913
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart() in /_/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.WorkerThread.NonBrowser.cs:line 102

Inner Exception 1:
MySqlException: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.

Inner Exception 2:
TimeoutException: The operation has timed out.
```System.AggregateException
  HResult=0x80131500
  Message=One or more errors occurred. (Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.)
  Source=System.Private.CoreLib
  StackTrace:
   at System.Threading.CancellationTokenSource.ExecuteCallbackHandlers(Boolean throwOnFirstException) in /_/src/libraries/System.Private.CoreLib/src/System/Threading/CancellationTokenSource.cs:line 831
   at System.Threading.TimerQueueTimer.Fire(Boolean isThreadPool) in /_/src/libraries/System.Private.CoreLib/src/System/Threading/Timer.cs:line 683
   at System.Threading.TimerQueue.FireNextTimers() in /_/src/libraries/System.Private.CoreLib/src/System/Threading/Timer.cs:line 331
   at System.Threading.ThreadPoolWorkQueue.Dispatch() in /_/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs:line 913
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart() in /_/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.WorkerThread.NonBrowser.cs:line 102

Inner Exception 1:
MySqlException: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.

Inner Exception 2:
TimeoutException: The operation has timed out.
```

How is this possible?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

string doesnt work?
C#CC# / help
4y ago
For-Loop doesnt work.
C#CC# / help
3y ago
Register user doesnt work (MySQL)
C#CC# / help
2y ago
✅ Why doesnt "this." work here?
C#CC# / help
2y ago