Accessing RabbitMQ Management UI of .NET Microservices Sample Reference Application eShopOnContainers

Analyzing Microsoft’s .NET Microservices Sample Reference Application eShopOnContainers, I also wanted to see what happens on the message bus used by the ‘local’ setup running on Docker Desktop. In this setup, the application is using RabbitMQ.

Access the RabbitMQ Login Page

Getting to the login page of the local container instance was quite simple. Having a quick look at docker-compose.override.yml, it shows that the UI is accessible via port 15672:

RabbitMQ UI Port

Entering localhost:15672 immediately opened the login page. Of course, one have to start the container instance previously 😉

RabbitMQ Login Page

Not bad that far.

What are the required Credentials?

Starting the container instances, some warnings are written out to the console that no variable is set for the service bus user and password, and that both will be set to the default value blank string.

Warning service bus user and password not set

Blank String does not work

Accordingly, I tried to leave both values blank, but the login failed.

RabbitMQ login failed with blank string

Set a custom User and Password

In the next step, I tried to set both values in the .env file of the app and configured the RabbitMQ container to use these values too by updating docker-compose.override.yml.
Snipped from .env

ESHOP_SERVICE_BUS_USERNAME=rabbit
ESHOP_SERVICE_BUS_PASSWORD=rabbitp

Snipped from docker-compose.override.yml

  rabbitmq:
    environment:
      - RABBITMQ_DEFAULT_USER=${ESHOP_SERVICE_BUS_USERNAME}
      - RABBITMQ_DEFAULT_PASS=${ESHOP_SERVICE_BUS_PASSWORD}
    ports:
      - "15672:15672"
      - "5672:5672"

This enabled me to login to RabbitMQ. And after some struggles with Docker and the service containers and images, I was able to login using my user and password, and the services were able to connect to RabbitMQ too.

A little bit better, but not fully satisfying.

Access without any Changes

Changing the source code is a little bit annoying. The services were able to connect without configuring the user and password, so why shouldn’t I?

I did some debugging to figure out which user and password the services are using. Searching for EventBusUserName showed me the place(s) where to add a breakpoint to see what’s the actual user and password.

It turns out that both user and password have the default value guest.

Well, and this value is well documented by RabbitMQ. The list of Core Server Variables Configurable in rabbitmq.conf shows the default values:

RabbitMQ documentation of default user and password

A well-known pattern: (almost) everything is documented, one just needs to know what exactly to search for 😉

Finally, I was able to login to the RabbitMQ management page by using guest as user and password, and no code changes were required.

RabbitMQ Managament

Links

Docker Desktop
Microsoft’s .NET Microservices Sample Reference Application eShopOnContainers
RabbitMQ
RabbitMQ’s list of Core Server Variables Configurable in rabbitmq.conf