UPDATE: As it turns out, the port that rabbitmq uses is not 15672. I changed the port number from 15672 to 5672 in ConnectionFactory block and connected successfully.
I've been trying to design a simple microservices architecture for trying and learning docker & rabbitmq. So I've written these docker-compose.yml file as seen below:
version: '3.4'
networks:
customqueue:
services:
feed.api:
image: feed.api:${TAG:-latest}
build:
context: .
dockerfile: src/Services/Feed/Feed.Api/Dockerfile
depends_on:
- sqldata
- rabbitmq
ports:
- "8000:80"
networks:
- customqueue
like.api:
image: like.api:${TAG:-latest}
build:
context: .
dockerfile: src/Services/Like/Like.Api/Dockerfile
depends_on:
- rabbitmq
ports:
- "7000:70"
networks:
- customqueue
rabbitmq:
image: rabbitmq:3-management-alpine
environment:
RABBITMQ_DEFAULT_USER: "admin"
RABBITMQ_DEFAULT_PASS: "password"
ports:
- "15672:15672"
- "5672:5672"
networks:
- customqueue
feed.api is designed to be a subscriber, like.api is designed to be a publisher. However, when i'm trying to run .net core code of feed.api, i'm getting this "None of the endpoints were reachable" error with RabbitMQ. RabbitMQ on container works fine. I'm trying to define a ConnectionFactory as below on Startup.cs in Feed.Api project.
var factory = new ConnectionFactory()
{
HostName = "rabbitmq",
UserName = "admin",
Password = "password",
Port = 15672,
Protocol = Protocols.DefaultProtocol,
RequestedConnectionTimeout = 2000,
VirtualHost = "/",
};
Note:
"admin" user is administrator.
rabbitmq-management plugin is enabled.
EDIT:rabbimq:3-managament-alpine is appearently is an old image. Updating this to latest version might help, but i'm not sure. Has anyone have an idea about it?