1、嗯,问题呢,就是一开始安装好RabbitMQ,练习了一下RabbitMQ的使用,但是呢,过了一段时间,我来复习的时候,发现运行出现下面的错误了。后来想想,是自己学习微服务的时候,修改了/etc/hosts的映射。后来又修改回去了,是不是感觉日了?了。解决方法如下所示:
eclipse远程连接服务器上面的Rabbitmq报的错误如下所示:
代码语言:javascript复制 1 org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused: connect
2 at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:62) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
3 at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:509) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
4 at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:684) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
5 at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.createConnection(ConnectionFactoryUtils.java:214) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
6 at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:1961) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
7 at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1935) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
8 at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1916) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
9 at org.springframework.amqp.rabbit.core.RabbitAdmin.getQueueProperties(RabbitAdmin.java:393) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
10 at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.redeclareElementsIfNecessary(AbstractMessageListenerContainer.java:1722) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
11 at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1026) [spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
12 at java.lang.Thread.run(Unknown Source) [na:1.8.0_191]
13 Caused by: java.net.ConnectException: Connection refused: connect
14 at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) ~[na:1.8.0_191]
15 at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source) ~[na:1.8.0_191]
16 at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) ~[na:1.8.0_191]
17 at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) ~[na:1.8.0_191]
18 at java.net.AbstractPlainSocketImpl.connect(Unknown Source) ~[na:1.8.0_191]
19 at java.net.PlainSocketImpl.connect(Unknown Source) ~[na:1.8.0_191]
20 at java.net.SocksSocketImpl.connect(Unknown Source) ~[na:1.8.0_191]
21 at java.net.Socket.connect(Unknown Source) ~[na:1.8.0_191]
22 at com.rabbitmq.client.impl.SocketFrameHandlerFactory.create(SocketFrameHandlerFactory.java:60) ~[amqp-client-5.4.3.jar:5.4.3]
23 at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1102) ~[amqp-client-5.4.3.jar:5.4.3]
24 at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1054) ~[amqp-client-5.4.3.jar:5.4.3]
25 at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:994) ~[amqp-client-5.4.3.jar:5.4.3]
26 at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:462) ~[spring-rabbit-2.1.2.RELEASE.jar:2.1.2.RELEASE]
27 ... 9 common frames omitted
28
29 2019-11-21 22:54:45.267 INFO 19532 --- [TaskExecutor-25] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [192.168.110.133:5672]
30 2019-11-21 22:54:49.261 WARN 19532 --- [TaskExecutor-24] 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: connect
31 2019-11-21 22:54:49.261 INFO 19532 --- [TaskExecutor-24] o.s.a.r.l.SimpleMessageListenerContainer : Restarting Consumer@3d06980: tags=[[]], channel=null, acknowledgeMode=AUTO local queue size=0
32 2019-11-21 22:54:49.262 INFO 19532 --- [TaskExecutor-25] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [192.168.110.133:5672]
33 2019-11-21 22:54:50.266 ERROR 19532 --- [TaskExecutor-25] o.s.a.r.l.SimpleMessageListenerContainer : Failed to check/redeclare auto-delete queue(s).
我修改的etc/hosts配置文件如下所示:
然后你再次使用eclipse远程访问rabbitmq的时候,应该已经正常了,未修改回来之前,我点击Rabbitmq的管控台overview的时候,反应超级慢的,改回来以后反应很快哦。 作者:别先生 博客园:https://www.cnblogs.com/biehongli/