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

Problem with accessing RabbitMQ - different hostname #3

Open
rmaziarka opened this issue Jul 11, 2018 · 5 comments
Open

Problem with accessing RabbitMQ - different hostname #3

rmaziarka opened this issue Jul 11, 2018 · 5 comments

Comments

@rmaziarka
Copy link

rmaziarka commented Jul 11, 2018

// 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?

@GooRiOn
Copy link
Member

GooRiOn commented Jul 12, 2018

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 ;)

@rmaziarka
Copy link
Author

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.

@GooRiOn
Copy link
Member

GooRiOn commented Jul 13, 2018

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?

@rmaziarka
Copy link
Author

Yes :)

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

@m1lwoj
Copy link

m1lwoj commented Aug 19, 2018

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

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

No branches or pull requests

3 participants