EasyNetQ: IAdvancedBus.IsConnected is no longer true right after the bus has been created

IAdvancedBus.IsConnected is no longer true right after the bus has been created. It’s flips to true after a call has been made with the bus.

var bus = RabbitHutch.CreateBus("host=localhost;username=myuser;password=mypass");
// bus.Advanced.IsConnected is false
await bus.PubSub.PublishAsync(new TestMsg());
// bus.Advanced.IsConnected is true

This has changed since 5.4.0

Is this intentionally or a bug?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 22 (9 by maintainers)

Commits related to this issue

Most upvoted comments

On version 5.6 we used the IAdvancedBus.IsConnected for one of our k8s healt checks. Due to this change this obviously no longer works. Any suggestions on a workaround for this? (Or will the old behavior of IsConnected will come back eventually - I can’t really tell form the conversation above)

Thanks for the use case. Will look for a solution.

On version 5.6 we used the IAdvancedBus.IsConnected for one of our k8s health checks. Due to this change this obviously no longer works. Any suggestions on a workaround for this? (Or will the old behaviour of IsConnected will come back eventually - I can’t really tell form the conversation above)

I think we should split up the configuring/start consuming, that would solve this.

In an ASP.NET Core I would build an IHostedService what would then start the bus, instead of a first message.

@alentor Here is the fix that solved this problem for me https://github.com/EasyNetQ/EasyNetQ/pull/1197

@Pliner It had an impact a long time ago when I started using EasyNetQ. When I made a connection I would wait for IsConnection to be true before starting to create exchanges or queues, if I didn’t wait I would sometimes get an error because the connection wasn’t established yet. This might’ve changed so this can’t occur any longer, I don’t know.