An unexpected connection driver error occurred when connecting to RabbitMQ in SpringBoot

question

In SpringBoot, when connecting to RabbitMQ, an error is reported, and the error message is roughly as follows:

2020-08-08 14:42:01.812 ERROR 2780 --- [92.168.1.6: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_181]
	at java.net.SocketInputStream.socketRead(SocketInputStream.java:116) ~[na:1.8.0_181]
	at java.net.SocketInputStream.read(SocketInputStream.java:171) ~[na:1.8.0_181]
	at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[na:1.8.0_181]
	at java.io.BufferedInputStream.fill(BufferedInputStream.java:246) ~[na:1.8.0_181]
	at java.io.BufferedInputStream.read(BufferedInputStream.java:265) ~[na:1.8.0_181]
	at java.io.DataInputStream.readUnsignedByte(DataInputStream.java:288) ~[na:1.8.0_181]
	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_181]

This error message is generally caused by permissions.

Troubleshoot

Log in to the RabiitMQ console and check:
insert image description hereinsert image description hereinsert image description hereFrom the above, it can be seen that there are permissions (if there is no permission, then configure it), so it can be determined that it is caused by incomplete configuration in SpringBoot.

solve

Add the configuration setting virtual machine name in SpringBoot's application.properties: spring.rabbitmq.virtual-host=my_vhost; the final configuration is as follows:

spring.rabbitmq.host=192.168.1.6
spring.rabbitmq.port=5672
spring.rabbitmq.username=fyk
spring.rabbitmq.password=fyk123
spring.rabbitmq.virtual-host=my_vhost

Guess you like

Origin blog.csdn.net/fyk844645164/article/details/107879657