DNC-DShop icon indicating copy to clipboard operation
DNC-DShop copied to clipboard

Problem with accessing RabbitMQ - different hostname

Open rmaziarka opened this issue 7 years ago • 5 comments

// there are so many repositories, that I don't know where I should put this issue ;)

I created the whole infrastructure by docker compose and tried to run the DShop.Api. And I encountered an error: An exception of type 'RabbitMQ.Client.Exceptions.BrokerUnreachableException' occurred in System.Private.CoreLib.dll but was not handled in user code: 'None of the specified endpoints were reachable'

I investigated that issue and found out that application uses appsettings.development.json file, where there is RabbitMQ configuration - "hostnames": [ "rabbitmq" ]

Unfortunately all resources are created by docker compose on localhost (there is no mentioning a different host), and application cannot connect to RabbitMQ which causes error.

When i hacked RabbitMQ configuration's resolving by rawRabbitConfiguration.Hostnames[0] = "localhost"; line in DShop.Common application started without problem.

My question - is this my problem with running this repo or did you make a mistake with configuration with RabbitMQ?

rmaziarka avatar Jul 11 '18 12:07 rmaziarka

How did you run DShop.Api? Was it via Docker image or Dotnet CLI?

As far as I remember the default appsettings.json contains localhost as a hostname, so you should be able to run it using dotnet run command. If you want to use Docker then I think you should go for docker-compose-local.yaml. That is because RabbitMQ container needs to be linked to API (in order to be visible as rabbitmq service).

Anyway, let me know how did you try to run it ;)

GooRiOn avatar Jul 12 '18 06:07 GooRiOn

I tried to run the application in 2 different approaches :D

  1. I run DShop.Api from Visual Studio Code. It automatically adds launch.json with "ASPNETCORE_ENVIRONMENT": "Development" so application tries to reach RabbitMQ at rabbitmq.

  2. I run docker-compose-infrastructure.yaml and then I run DShop.Api in Docker by Dockerfile. But then it doesn't see RabbitMQ because it is in a different network.

For the second one, I can add a network to compose files to allow running different docker containers with a connection to this network.

rmaziarka avatar Jul 12 '18 21:07 rmaziarka

I'm not quite sure why do we have rabbitmq in Development. Maybe @spetz could answer that. I think we should simply change it to localhost. Would that be ok for you?

GooRiOn avatar Jul 13 '18 08:07 GooRiOn

Yes :)

But what about option 2 - is it OK to add network information to compose files?

rmaziarka avatar Jul 18 '18 08:07 rmaziarka

@GooRiOn For my instance using default RabbitMQ settings and changing to "hostnames": [ "localhost" ] in appsettings.json file worked.

m1lwoj avatar Aug 19 '18 18:08 m1lwoj