为了账号安全,请及时绑定邮箱和手机立即绑定

运行报错org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused: connect

  我项目运行消息没有发送,报错信息是这样

org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused: connect

at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:62)

at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:509)

at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:682)

at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.createConnection(ConnectionFactoryUtils.java:214)

at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:2061)

at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:2035)

at org.springframework.amqp.rabbit.core.RabbitTemplate.send(RabbitTemplate.java:982)

at org.springframework.amqp.rabbit.core.RabbitTemplate.convertAndSend(RabbitTemplate.java:1048)

at com.bfxy.springboot.producer.OrderSender.send(OrderSender.java:20)

at com.bfxy.springboot.ApplicationTests.testSende1(ApplicationTests.java:32)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)

at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)

at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74)

at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84)

at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)

at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)

at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)

at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)

at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)

at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)

at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)

at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)

at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)

at org.junit.runners.ParentRunner.run(ParentRunner.java:363)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)

at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)

at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

Caused by: java.net.ConnectException: Connection refused: connect

at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)

at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)

at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)

at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)

at java.net.AbstractPlainSocketImpl.connect(Unknown Source)

at java.net.PlainSocketImpl.connect(Unknown Source)

at java.net.SocksSocketImpl.connect(Unknown Source)

at java.net.Socket.connect(Unknown Source)

at com.rabbitmq.client.impl.SocketFrameHandlerFactory.create(SocketFrameHandlerFactory.java:60)

at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1102)

at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1054)

at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:994)

at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:462)

... 39 more

这个我查了一下好像是拒绝连接了,但是我web登录管控台是可以的https://img1.sycdn.imooc.com//5c9339dc0001eb2b04180271.jpg

正在回答

4 回答

请问你的问题解决了吗?可以分享一下解决方案吗

0 回复 有任何疑惑可以回复我~

把address改成host就好了http://img1.sycdn.imooc.com//5dc0eb330001108805390233.jpg

0 回复 有任何疑惑可以回复我~

guest用户默认连接本机ip,就会报这个错,不耽误使用RabbitMQ。解决:可以新建一个用户

0 回复 有任何疑惑可以回复我~

检查防火墙关了没,管控台和消息发送的端口不是一个,有可能是防火墙阻拦了

0 回复 有任何疑惑可以回复我~
#1

慕用5758374 提问者

我是阿里云的服务器 防火墙关了 安全组也打开了5672还是一样的问题
2019-03-28 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

运行报错org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused: connect

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信