davidfowl / BedrockFramework

High performance, low level networking APIs for building custom servers and clients.
MIT License
1.05k stars 153 forks source link

Unobserved task exception caught while calling ConnectAsync #61

Open robertmircea opened 4 years ago

robertmircea commented 4 years ago

How should I handle this internal exception which is thrown by Client.ConnectAsync? I received this exception while trying to connect to a host which was temporarily down and connection timed out.

This is the entire stacktrace, nothing was removed. I have a handler for unobserved task exceptions which only logs the message (as below).

00:36:51.305 ERROR  [ThrId=02] Unobserved task exception caught in the main AppDomain. System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (60): Operation timed out [::ffff:172.16.x.y]:15019
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Exception source)
   at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
   at System.Net.Sockets.Socket.<>c.<ConnectAsync>b__274_0(IAsyncResult iar)
--- End of stack trace from previous location where exception was thrown ---
   at Bedrock.Framework.SocketConnection.StartAsync()
   at Bedrock.Framework.Client.ConnectAsync(EndPoint endpoint, CancellationToken cancellationToken)
davidfowl commented 4 years ago

There shouldn't be any unobserved tasks, it just sounds like a bug that needs to be fixed.