Kubernetes: RabbitMQ Client could not connect. (None of the specified endpoints were reachable)

1/10/2020

When I use RabbitMQ from localhost, I supply my RabbitMQConnectionString as localhost in my ASP.NET Core WebApi and everything works fine.

But I wanted to use RabbitMQ from a Kubernetes Cluster, so, I created a new Namespace in Kubernetes Cluster for RabbitMQ, then I created an app from the Kubernetes Dashboard with the image: rabbitmq:management I specified External Service with Port and target Port as 15672 for both. And waited for it to be deployed.

I can access the management portal of RabbitMQ with the External IP of service: xx.xx.153.133:15672 in the browser, but When I use this IP with port as RabbitMQConnectionString in my ASP.NET Core WebApi, it gives me the following error(through seq):

Seq 1

And when I supply IP only i.e. xx.xx.153.133, it searches RabbitMQ on 5672 instead of 15672 and gives me the following error:

Seq 2

Can someone please guide me through on how to proceed and fix the error.

-- Achal Sharma
asp.net-core-webapi
azure-kubernetes
kubernetes
rabbitmq

1 Answer

1/10/2020

I figured it out, I added all 3 ports on Kubernetes now: 15672, 5672, 25672. And used only the IP as the RabbitMQConnectionString. It then automatically uses 5672 port to send & receive messages.

-- Achal Sharma
Source: StackOverflow