-
Notifications
You must be signed in to change notification settings - Fork 623
Description
It appears that SslSession does not always handle all the exceptions coming from async actions on SslStream. An example of internal exception stack trace:
System.IO.IOException: Unable to read data from the transport connection: Operation canceled. ?, in void AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken) ?, in async ValueTask<int> SslStream.EnsureFullTlsFrameAsync<TIOAdapter>(CancellationToken cancellationToken, int estimatedSize) ?, in async ValueTask<int> SslStream.ReadAsyncInternal<TIOAdapter>(Memory<byte> buffer, CancellationToken cancellationToken) ?, in static ValueTaskSourceAsTask()+(object state) => { }
It seems that this unobserved exception appears when SslSession is disposed (or disconnected) from server side, while the receive task is still pending. My assumption is that disconnecting SslSession creates a race condition on IsHandshaked property, which is considered in ProcessReceive() before invoking SslStream.EndRead, which is necessary to catch any exception which may have happened in SslStream read task. This may also happen in during other phases, such as handshake or sending.
NetCoreServer version:
8.0.7