Error: 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.00.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]Copy the code

Thought there was a problem with the port. Check the Docker port mapping

PS C:\Users\wangn> docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 8b2958c71e85 The 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 myrabbitCopy the code

no problem ‘

A visit to Google didn’t work out.

Until I add the application. Properties file

spring.rabbitmq.host=localhost
Copy the code

Switch to

Spring. The rabbitmq. Host = 10.0.75.2Copy the code

No errors are reported on startup.

10.0.75.2 is the IP address of the Docker container