Pivotal Knowledge Base

Follow

Spring Cloud DataFlow Error: "AmqpConnectException: java.net.ConnectException: Connection refused"

Environment 

 Product  Version
 Spring Cloud DataFlow (SCDF)  1.0.x, 1.1.x
 RabbitMQ  All versions 

Overview

This article provides a way to resolve the error: AmqpConnectException: java.net.ConnectException: Connection refused on Spring Cloud DataFlow (SCDF) when you try to deploy a stream.

Symptom

Spring Cloud DataFlow fails with the following error when you try to deploy a stream

2016-10-19 11:47:47.159 INFO 65071 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer :
Tomcat started on port(s): 33910 (http) 2016-10-19 11:47:47.163 INFO 65071 --- [ main] o.s.c.s.a.l.s.r.LogSinkRabbitApplication :
Started LogSinkRabbitApplication in 12.202 seconds (JVM running for 13.157) 2016-10-19 11:47:52.090 WARN 65071 ---
[http.httptest-1] o.s.a.r.l.SimpleMessageListenerContainer :
Consumer raised exception, processing can restart if the connection factory supports it.
Exception summary: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused

Cause 

This is usually caused if a RabbitMQ service was not bound properly to the application.

Resolution

1. If you have not created a RabbitMQ service, create one using

cf create-service cloudamqp lemur rabbit

2. You have to pass "rabbit" service name via SPRING_CLOUD_DEPLOYER_CLOUDFOUNDRY_STREAM_SERVICES. The environment variable SPRING_CLOUD_DEPLOYER_CLOUDFOUNDRY_STREAM_SERVICES k/v pair from Spring Cloud Data Flow perspective, but when SCDF deploys the apps, it iterates over the list and binds the named serviced to the apps automatically

cf set-env dataflow-server SPRING_CLOUD_DEPLOYER_CLOUDFOUNDRY_STREAM_SERVICES rabbit

If you are not running SCDF on Pivotal Cloud Foundry or locally, set the environment variable; this would depend on what OS you are using

export SPRING_CLOUD_DEPLOYER_CLOUDFOUNDRY_STREAM_SERVICES=rabbit

Additional Information

In a nutshell, whenever you deploy a stream successfully (With apps in it), each one of the app is looked up and resolved from the configured maven repository and it gets cached. So, every new app goes through this cycle at least once and then it gets cached until there's a new version of the same app artifact.

It does take 1-2 minutes with the first stream deployment attempts and when you repeat the deploys, it will be faster. When this happens, the stream status changes from failed to deploying to deployed.

For more information on deploying modules on cloud foundry using SCDF, see here.

Comments

Powered by Zendesk