Lucas Crostarosa
Lucas Crostarosa

Reputation: 1192

Rabbit MQ Fails to start with Spring Boot Run (Connection Refused)

I was going to post this question but I think I've found an answer. I'm hoping someone can provide a reason why to further public knowledge.

I am integrating RabbitMQ into my Spring Boot Application.

Upon startup of my Spring boot Application I keep getting this stack trace

org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused (Connection refused)
    at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:62) ~[spring-rabbit-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:484) ~[spring-rabbit-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:626) ~[spring-rabbit-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.createConnection(ConnectionFactoryUtils.java:240) ~[spring-rabbit-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:1797) ~[spring-rabbit-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1771) ~[spring-rabbit-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1752) ~[spring-rabbit-2.0.5.RELEASE.jar:2.0.5.RELEASE]
... 
Caused by: java.net.ConnectException: Connection refused (Connection refused)
    at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_172]
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_172]
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_172]
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_172]
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_172]

I've cut RabbitMQ to bare bones and only have the dependency in the pom.xml and have the following in application.properties

spring.rabbitmq.host=localhost
spring.rabbitmq.port=15672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest

I verified that Rabbit MQ was up and running and could even go into the GUI

My solution was to change spring.rabbitmq.port to 5672 (removing the 1)

Can anyone provide a technical answer? Is it because RabbitMQ listens on that port 5672 and provides the front end only on 15672

Upvotes: 0

Views: 2412

Answers (1)

Aksanth
Aksanth

Reputation: 319

RabbitMq uses Advanced Message Queuing Protocol (AMQP).

In rabbitmq.conf the tcp port provided takes the port of the RabbitMq from your Java Application.

listeners.tcp.default = 5672

RabbitMQ Management console or the Web Admin uses the 15672 (default) port.

Upvotes: 4

Related Questions