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

Throw exception during CreateConnectionAsync in case of wrong credentials #1777

Closed
lukebakken opened this issue Jan 27, 2025 · 0 comments · Fixed by #1781
Closed

Throw exception during CreateConnectionAsync in case of wrong credentials #1777

lukebakken opened this issue Jan 27, 2025 · 0 comments · Fixed by #1781
Assignees
Milestone

Comments

@lukebakken
Copy link
Contributor

Discussed in #1776

Originally posted by plewam January 27, 2025
Hello,

I create a new IConnection using below call.

Connection = await ConnectionFactory.CreateConnectionAsync(cancellationToken).ConfigureAwait(false);

Inside the ConnectionFactory I have to specify Hostname, Port, UserName and so. In case the host is not reachable the above call will give me a BrokerUnreachableException which is the desired behaviour. However in case the combination of UserName and Password is wrong, the above call will succeed. The IConnection object is also set and initialised. This causes my application to continue to subscribe to queues and so on. However shortly after the above call I will receive a ConnectionShutdown event which tells me that the credentials are wrong. From that moment on the IConnection object is also Null.

This behaviour causes a lot of NullReferenceExceptions throughout my application code. Ideally the CreateConnectionAsync call will throw an exception immediately telling me that the credentials are wrong. This way I can abort the further subscribing to queues immediately.

Kind regards,

Mathis

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

Successfully merging a pull request may close this issue.

1 participant