仅在Heroku上拒绝CloudAMQP连接

时间:2019-03-14 00:57:16

标签: java spring-boot heroku rabbitmq cloudamqp

我正在为Spring Boot应用程序使用CloudAMQP Heroku Add On。我正在本地和Heroku上使用“ CLOUDAMQP_URL”环境变量连接到服务。

在本地,我的环境变量是:amqp:// guest:guest @ localhost:5672

在Heroku上,我的环境变量是由Heroku生成的,类似于:amqp:// oilpmoxc:rGoLFAKEPASSWORDhhqwwk6g@lion.rmq.cloudamqp.com/oilpmoxc

我知道Heroku生成的环境变量是正确的,因为我抓住了它并在本地使用了它。我可以连接到Heroku提供的CloudAWQP实例。

有一次,我在Heroku上的应用程序可以很好地连接到CloudAMQP。没问题。现在,我根本无法连接。我一直收到“拒绝连接”错误。

以下是日志的转储。

2019-03-14T00:55:24.586687+00:00 app[web.1]: java.net.ConnectException: Connection refused (Connection refused)
2019-03-14T00:55:24.587055+00:00 app[web.1]:    at java.net.PlainSocketImpl.socketConnect(Native Method)
2019-03-14T00:55:24.587122+00:00 app[web.1]:    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
2019-03-14T00:55:24.587220+00:00 app[web.1]:    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
2019-03-14T00:55:24.587282+00:00 app[web.1]:    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
2019-03-14T00:55:24.587356+00:00 app[web.1]:    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
2019-03-14T00:55:24.587431+00:00 app[web.1]:    at java.net.Socket.connect(Socket.java:589)
2019-03-14T00:55:24.587491+00:00 app[web.1]:    at com.rabbitmq.client.impl.SocketFrameHandlerFactory.create(SocketFrameHandlerFactory.java:60)
2019-03-14T00:55:24.587610+00:00 app[web.1]:    at com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory.newConnection(RecoveryAwareAMQConnectionFactory.java:62)
2019-03-14T00:55:24.587755+00:00 app[web.1]:    at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.init(AutorecoveringConnection.java:156)
2019-03-14T00:55:24.587820+00:00 app[web.1]:    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1106)
2019-03-14T00:55:24.587896+00:00 app[web.1]:    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1063)
2019-03-14T00:55:24.588121+00:00 app[web.1]:    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1021)
2019-03-14T00:55:24.588185+00:00 app[web.1]:    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1182)
2019-03-14T00:55:24.588267+00:00 app[web.1]:    at com.noebrito.temptube.messaging.MessageReceiver.pollQueue(MessageReceiver.java:41)
2019-03-14T00:55:24.588345+00:00 app[web.1]:    at com.noebrito.temptube.util.ScheduledTask.deleteExpiredVideos(ScheduledTask.java:39)
2019-03-14T00:55:24.588401+00:00 app[web.1]:    at sun.reflect.GeneratedMethodAccessor73.invoke(Unknown Source)
2019-03-14T00:55:24.588489+00:00 app[web.1]:    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2019-03-14T00:55:24.588700+00:00 app[web.1]:    at java.lang.reflect.Method.invoke(Method.java:498)
2019-03-14T00:55:24.588761+00:00 app[web.1]:    at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84)
2019-03-14T00:55:24.588856+00:00 app[web.1]:    at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
2019-03-14T00:55:24.588921+00:00 app[web.1]:    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
2019-03-14T00:55:24.588997+00:00 app[web.1]:    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
2019-03-14T00:55:24.589220+00:00 app[web.1]:    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
2019-03-14T00:55:24.589284+00:00 app[web.1]:    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
2019-03-14T00:55:24.589362+00:00 app[web.1]:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
2019-03-14T00:55:24.589438+00:00 app[web.1]:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
2019-03-14T00:55:24.589499+00:00 app[web.1]:    at java.lang.Thread.run(Thread.java:748)
2019-03-14T00:55:24.589945+00:00 app[web.1]: 2019-03-14 00:55:24.589 ERROR 4 --- [   scheduling-1] c.n.temptube.messaging.MessageReceiver   : Connection refused (Connection refused)

任何人都知道发生了什么事吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

最后知道了...

本质上,在使用工厂创建连接之前,我需要将URI设置为工厂对象。这很奇怪,因为在本地运行时不需要此顺序。很奇怪,但是哦。可以。