RabbitMq 本地连接报错 org.springframework.amqp.AmqpIOException: java.io.IOException
前言
上一篇博客講述了ubuntu 16.04上如何安裝RabbitMq,并通過web管理界面遠程訪問。
緊接著我在自己搭建的spring boot項目中,整合了RabbitMq,本地啟動項目,發現控制臺一直報錯。。。
項目啟動報錯
org.springframework.amqp.AmqpIOException: java.io.IOException….
具體報錯如下截圖:
2018-08-15 15:13:14.841 ?WARN 298648 --- [232.54.105:5672] c.r.c.impl.ForgivingExceptionHandler ? ? : An unexpected connection driver error occured (Exception message: Connection reset)
2018-08-15 15:13:14.843 ?INFO 298648 --- [cTaskExecutor-2] o.s.a.r.c.CachingConnectionFactory ? ? ? : Attempting to connect to: [132.232.54.105:5672]
2018-08-15 15:13:14.846 ERROR 298648 --- [cTaskExecutor-2] o.s.a.r.l.SimpleMessageListenerContainer : Failed to check/redeclare auto-delete queue(s).
org.springframework.amqp.AmqpIOException: java.io.IOException
? ? at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:71) ~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE]
? ? at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:476) ~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE]
? ? at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:614) ~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE]
? ? at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.createConnection(ConnectionFactoryUtils.java:240) ~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE]
? ? at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:1797) ~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE]
? ? at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1771) ~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE]
? ? at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1752) ~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE]
? ? at org.springframework.amqp.rabbit.core.RabbitAdmin.getQueueProperties(RabbitAdmin.java:338) ~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE]
? ? at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.redeclareElementsIfNecessary(AbstractMessageListenerContainer.java:1604) ~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE]
? ? at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:963) [spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE]
? ? at java.lang.Thread.run(Thread.java:748) [na:1.8.0_131]
Caused by: java.io.IOException: null
? ? at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:126) ~[amqp-client-5.1.2.jar:5.1.2]
? ? at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:122) ~[amqp-client-5.1.2.jar:5.1.2]
? ? at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:144) ~[amqp-client-5.1.2.jar:5.1.2]
? ? at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:390) ~[amqp-client-5.1.2.jar:5.1.2]
? ? at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:957) ~[amqp-client-5.1.2.jar:5.1.2]
? ? at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:907) ~[amqp-client-5.1.2.jar:5.1.2]
? ? at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:847) ~[amqp-client-5.1.2.jar:5.1.2]
? ? at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:449) ~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE]
? ? ... 9 common frames omitted
Caused by: com.rabbitmq.client.ShutdownSignalException: connection error
? ? at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:66) ~[amqp-client-5.1.2.jar:5.1.2]
? ? at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:36) ~[amqp-client-5.1.2.jar:5.1.2]
? ? at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:494) ~[amqp-client-5.1.2.jar:5.1.2]
? ? at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:288) ~[amqp-client-5.1.2.jar:5.1.2]
? ? at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:138) ~[amqp-client-5.1.2.jar:5.1.2]
? ? ... 14 common frames omitted
Caused by: java.net.SocketException: Connection reset
? ? at java.net.SocketInputStream.read(SocketInputStream.java:210) ~[na:1.8.0_131]
? ? at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[na:1.8.0_131]
? ? at java.io.BufferedInputStream.fill(BufferedInputStream.java:246) ~[na:1.8.0_131]
? ? at java.io.BufferedInputStream.read(BufferedInputStream.java:265) ~[na:1.8.0_131]
? ? at java.io.DataInputStream.readUnsignedByte(DataInputStream.java:288) ~[na:1.8.0_131]
? ? at com.rabbitmq.client.impl.Frame.readFrom(Frame.java:91) ~[amqp-client-5.1.2.jar:5.1.2]
? ? at com.rabbitmq.client.impl.SocketFrameHandler.readFrame(SocketFrameHandler.java:164) ~[amqp-client-5.1.2.jar:5.1.2]
? ? at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:580) ~[amqp-client-5.1.2.jar:5.1.2]
? ? ... 1 common frames omitted
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
問題分析
其實在我上一家公司,開發過程中,本地啟動項目也會一直報這個錯!!
首先,我確定rabbitmq正常啟動了,可以遠程訪問,且項目中配置文件是正確的:
# ?rabbitmq:
# ? ?host: 127.0.0.1
# ? ?port: 5672
# ? ?virtual-host: /
# ? ?username: guest # 默認的guest用戶
# ? ?password: guest
? rabbitmq:
? ? ? host: 132.232.54.106 ? # 服務器IP
? ? ? port: 5672 ? ?# 端口
? ? ? virtual-host: /
? ? ? username: demo ? #新增用戶名
? ? ? password: demo
1
2
3
4
5
6
7
8
9
10
11
12
13
將rabbitmq主機改為127.0.0.1,username:guest。然后將項目打成war包,放到安裝rabbitmq的服務器上面運行。
啟動成功后,本地瀏覽器訪問項目swagger接口,并調用測試接口,查看日志,是ok的。
經過一番百度,最終得到的解決辦法:
將rabbitmq新增的用戶授權就可以了。具體解決辦法如下:
操作步驟:
1.打開RabbitMq web管理界面,進入該頁面,點擊用戶名稱
2.點擊 set premission 按鈕,就ok了
over,這個時候再去本地啟動一下項目,使用這個用戶。。是不是發現就沒報錯了。QAQ
最后說一下,rabbitmq的這個可視化工具還是挺好用的。
————————————————
版權聲明:本文為CSDN博主「好軟好可愛啊」的原創文章,遵循CC 4.0 BY-SA版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/qq_22638399/article/details/81705606
總結
以上是生活随笔為你收集整理的RabbitMq 本地连接报错 org.springframework.amqp.AmqpIOException: java.io.IOException的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 网上银行跨行转账需要手续费吗
- 下一篇: 职业教育板块有哪些上市公司 想入局教育行