rabbitmq Attempting to connect to: [localhost:5672] SocketExceptio:Socket Closed

今天使用spring cloud stream for rabbitmq启动项目报错:

2019-05-03 13:22:27.350  INFO [file,,,] 18160 --- [           main] o.s.a.r.c.CachingConnectionFactory       : Attempting to connect to: [localhost:5672]
2019-05-03 13:22:32.382 ERROR [file,,,] 18160 --- [ 127.0.0.1:5672] c.r.c.impl.ForgivingExceptionHandler     : An unexpected connection driver error occured

java.net.SocketException: Socket Closed
	at java.net.SocketInputStream.socketRead0(Native Method) ~[na:1.8.0_191]
	at java.net.SocketInputStream.socketRead(SocketInputStream.java:116) ~[na:1.8.0_191]
	at java.net.SocketInputStream.read(SocketInputStream.java:171) ~[na:1.8.0_191]
	at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[na:1.8.0_191]
	at java.io.BufferedInputStream.fill(BufferedInputStream.java:246) ~[na:1.8.0_191]
	at java.io.BufferedInputStream.read(BufferedInputStream.java:265) ~[na:1.8.0_191]
	at java.io.DataInputStream.readUnsignedByte(DataInputStream.java:288) ~[na:1.8.0_191]
	at com.rabbitmq.client.impl.Frame.readFrom(Frame.java:91) ~[amqp-client-5.4.3.jar:5.4.3]
	at com.rabbitmq.client.impl.SocketFrameHandler.readFrame(SocketFrameHandler.java:164) ~[amqp-client-5.4.3.jar:5.4.3]
	at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:596) ~[amqp-client-5.4.3.jar:5.4.3]
	at java.lang.Thread.run(Thread.java:748) [na:1.8.0_191]
复制代码

以为端口有问题。检查了下Docker的端口映射

PS C:\Users\wangn> docker ps
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                                                                                                                      NAMES
8b2958c71e85        rabbitmq:3.7.14-management   "docker-entrypoint.s…"   About an hour ago   Up About an hour    0.0.0.0:4369->4369/tcp, 0.0.0.0:5671-5672->5671-5672/tcp, 0.0.0.0:15671-15672->15671-15672/tcp, 0.0.0.0:25672->25672/tcp   myrabbit
复制代码

没问题。‘

去谷歌了一遍也没有解决。

直到我将application.properties文件中的

spring.rabbitmq.host=localhost
复制代码

换成

spring.rabbitmq.host=10.0.75.2
复制代码

启动就不报错了。

其中10.0.75.2是docker容器的IP地址

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值