Skip to content

Fix #1777 #1781

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

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions projects/RabbitMQ.Client/Impl/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -793,13 +793,18 @@ protected async Task<bool> HandleConnectionCloseAsync(IncomingCommand cmd, Cance
var reason = new ShutdownEventArgs(ShutdownInitiator.Peer, method._replyCode, method._replyText, method._classId, method._methodId);
try
{
await Session.Connection.ClosedViaPeerAsync(reason, cancellationToken)
.ConfigureAwait(false);

/*
* rabbitmq-dotnet-client#1777
* Send the connection.close-ok message prior to closing within the client,
* because ClosedViaPeerAsync will stop the main loop
*/
var replyMethod = new ConnectionCloseOk();
await ModelSendAsync(in replyMethod, cancellationToken)
.ConfigureAwait(false);

await Session.Connection.ClosedViaPeerAsync(reason, cancellationToken)
.ConfigureAwait(false);

SetCloseReason(Session.Connection.CloseReason!);
}
catch (IOException)
Expand Down
18 changes: 18 additions & 0 deletions projects/Test/Integration/GH/TestGitHubIssues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
using System.Threading.Tasks;
using RabbitMQ.Client;
using RabbitMQ.Client.Events;
using RabbitMQ.Client.Exceptions;
using Xunit;
using Xunit.Abstractions;

Expand Down Expand Up @@ -147,5 +148,22 @@ public async Task DisposeWhileCatchingTimeoutDeadlocksRepro_GH1759()

await _conn.DisposeAsync();
}

[Fact]
public async Task InvalidCredentialsShouldThrow_GH1777()
{
string userPass = Guid.NewGuid().ToString();

_connFactory = new ConnectionFactory
{
UserName = userPass,
Password = userPass
};

BrokerUnreachableException ex =
await Assert.ThrowsAnyAsync<BrokerUnreachableException>(
async () => await _connFactory.CreateConnectionAsync());
Assert.IsAssignableFrom<PossibleAuthenticationFailureException>(ex.InnerException);
}
}
}