Skip to content

Spurious error logged if connection is cancelled #1544

@bgrainger

Description

@bgrainger

Software versions
MySqlConnector version: 2.4.0
Server type (MySQL, MariaDB, Aurora, etc.) and version:
.NET version: 8.0

Describe the bug
If connecting is canceled during TLS negotiation, MySqlConnector may log a spurious error: ERROR Session 1.1 couldn't initialize TLS connection

Exception

System.Threading.Tasks.TaskCanceledException: A task was canceled.
   at async Task System.Net.Security.SslStream.ForceAuthenticationAsync<TIOAdapter>(bool receiveFirst, byte[] reAuthenticationData, CancellationToken cancellationToken)
   at async Task MySqlConnector.Core.ServerSession.InitSslAsync(ProtocolCapabilities serverCapabilities, ConnectionSettings cs, MySqlConnection connection, SslProtocols sslProtocols, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/ServerSession.cs:line 1691

Expected behavior
Should be logged at Debug level at most.

Additional context

Don't log for OperationCanceledException here: https://github.com/mysql-net/MySqlConnector/blob/2.4.0/src/MySqlConnector/Core/ServerSession.cs#L1731-L1733

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions