Closed scottf closed 6 months ago
That code was to mark the exception as observed. Without reading task.Exception
you'll end up with an unhandled exception. ~We likely don't want that.~
Edit: I see where the move to Wait will raise this as an aggregate exception instead.
Analysis
When a TLS connection fails, in this case the server being connected to is not even on-line, the next connection attempt sometimes freezes. It was intermittent, but reproducible. See code at end.
With some debugging, I could see where it was freezing, but it looked like it was inside the .net library code. What I noticed is that the connect code seemed overly complicated to me, and there was this
GC.KeepAlive(t.Exception);
. At the end of the day, we don't care why it failed, we just want to move on. So I simplified the code.There was a corresponding TLS Handshake error in the server log.
Since this change, I cannot reproduce the problem and the error is not appearing in the server log.
Code To Reproduce