diff --git a/projects/RabbitMQ.Client/client/api/IConnection.cs b/projects/RabbitMQ.Client/client/api/IConnection.cs
index 4078e005af..11653032a1 100644
--- a/projects/RabbitMQ.Client/client/api/IConnection.cs
+++ b/projects/RabbitMQ.Client/client/api/IConnection.cs
@@ -244,6 +244,7 @@ public interface IConnection : INetworkConnection, IDisposable
///
/// Asynchronously create and return a fresh channel, session, and channel.
///
+ // TODO cancellation token
ValueTask CreateChannelAsync();
}
}
diff --git a/projects/RabbitMQ.Client/client/impl/AutorecoveringConnection.Recovery.cs b/projects/RabbitMQ.Client/client/impl/AutorecoveringConnection.Recovery.cs
index b55cd33ce0..28eab5f41f 100644
--- a/projects/RabbitMQ.Client/client/impl/AutorecoveringConnection.Recovery.cs
+++ b/projects/RabbitMQ.Client/client/impl/AutorecoveringConnection.Recovery.cs
@@ -560,6 +560,7 @@ public RecoveryChannelFactory(IConnection connection)
_connection = connection;
}
+ // TODO cancellation token
public async ValueTask CreateRecoveryChannelAsync()
{
if (_recoveryChannel == null)
diff --git a/projects/RabbitMQ.Client/client/impl/ChannelBase.cs b/projects/RabbitMQ.Client/client/impl/ChannelBase.cs
index 61ab49b025..4aa0c31f16 100644
--- a/projects/RabbitMQ.Client/client/impl/ChannelBase.cs
+++ b/projects/RabbitMQ.Client/client/impl/ChannelBase.cs
@@ -968,18 +968,20 @@ protected void HandleConnectionStart(in IncomingCommand cmd)
var reason = new ShutdownEventArgs(ShutdownInitiator.Library, Constants.CommandInvalid, "Unexpected Connection.Start");
Session.Connection.Close(reason, false, InternalConstants.DefaultConnectionCloseTimeout);
}
-
- var method = new ConnectionStart(cmd.MethodSpan);
- var details = new ConnectionStartDetails
+ else
{
- m_versionMajor = method._versionMajor,
- m_versionMinor = method._versionMinor,
- m_serverProperties = method._serverProperties,
- m_mechanisms = method._mechanisms,
- m_locales = method._locales
- };
- m_connectionStartCell?.SetResult(details);
- m_connectionStartCell = null;
+ var method = new ConnectionStart(cmd.MethodSpan);
+ var details = new ConnectionStartDetails
+ {
+ m_versionMajor = method._versionMajor,
+ m_versionMinor = method._versionMinor,
+ m_serverProperties = method._serverProperties,
+ m_mechanisms = method._mechanisms,
+ m_locales = method._locales
+ };
+ m_connectionStartCell.SetResult(details);
+ m_connectionStartCell = null;
+ }
}
finally
{
diff --git a/projects/RabbitMQ.Client/client/impl/Connection.Commands.cs b/projects/RabbitMQ.Client/client/impl/Connection.Commands.cs
index 057b8d107a..ce92007fff 100644
--- a/projects/RabbitMQ.Client/client/impl/Connection.Commands.cs
+++ b/projects/RabbitMQ.Client/client/impl/Connection.Commands.cs
@@ -76,11 +76,7 @@ private async ValueTask StartAndTuneAsync(CancellationToken cancellationToken)
using CancellationTokenRegistration ctr = cancellationToken.Register(() =>
{
- if (connectionStartCell.TrySetCanceled())
- {
- // TODO anything to do here?
- // connectionStartCell.TrySetResult(null);
- }
+ connectionStartCell.TrySetCanceled(cancellationToken);
}, useSynchronizationContext: false);
_channel0.m_connectionStartCell = connectionStartCell;
@@ -90,10 +86,10 @@ private async ValueTask StartAndTuneAsync(CancellationToken cancellationToken)
await _frameHandler.SendProtocolHeaderAsync(cancellationToken)
.ConfigureAwait(false);
- ConnectionStartDetails connectionStart = await connectionStartCell.Task
- .ConfigureAwait(false);
+ Task csct = connectionStartCell.Task;
+ ConnectionStartDetails connectionStart = await csct.ConfigureAwait(false);
- if (connectionStart is null)
+ if (connectionStart is null || csct.IsCanceled)
{
const string msg = "connection.start was never received, likely due to a network timeout";
throw new IOException(msg, _channel0.ConnectionStartException);
@@ -125,6 +121,7 @@ await _frameHandler.SendProtocolHeaderAsync(cancellationToken)
if (challenge is null)
{
// TODO cancellationToken
+ // Note: when token is passed, OperationCanceledException could be raised
res = await _channel0.ConnectionStartOkAsync(ClientProperties,
mechanismFactory.Name,
response,
@@ -133,6 +130,7 @@ await _frameHandler.SendProtocolHeaderAsync(cancellationToken)
else
{
// TODO cancellationToken
+ // Note: when token is passed, OperationCanceledException could be raised
res = await _channel0.ConnectionSecureOkAsync(response)
.ConfigureAwait(false);
}