Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnobservedTaskException containing System.IO.IOException (using SslServer) #322

Open
vilshus opened this issue Nov 13, 2024 · 1 comment

Comments

@vilshus
Copy link

vilshus commented Nov 13, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@vilshus and others