已解决:ERROR com.rabbitmq.client.impl.ForgivingExceptionHandler - An unexpected connection driver error

ERROR com.rabbitmq.client.impl.ForgivingExceptionHandler - An unexpected connection driver error occurred java.net.SocketException: Socket Closed

java 连接Rabbitmq-server时报错

java.util.concurrent.TimeoutException
	at com.rabbitmq.utility.BlockingCell.get(BlockingCell.java:77)
	at com.rabbitmq.utility.BlockingCell.uninterruptibleGet(BlockingCell.java:120)
	at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:36)
	at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:502)
	at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:326)
	at com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory.newConnection(RecoveryAwareAMQConnectionFactory.java:65)
	at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.init(AutorecoveringConnection.java:160)
	at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1216)
	at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1173)
	at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1310)
	at com.su.simple.Producer.main(Producer.java:30)
21:55:40.342 [AMQP Connection 121.89.219.240:15672] ERROR com.rabbitmq.client.impl.ForgivingExceptionHandler - An unexpected connection driver error occurred
java.net.SocketException: Socket Closed
	at java.net.SocketInputStream.socketRead0(Native Method)
	at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
	at java.net.SocketInputStream.read(SocketInputStream.java:171)
	at java.net.SocketInputStream.read(SocketInputStream.java:141)
	at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
	at java.io.BufferedInputStream.read(BufferedInputStream.java:265)
	at java.io.DataInputStream.readUnsignedByte(DataInputStream.java:288)
	at com.rabbitmq.client.impl.Frame.readFrom(Frame.java:91)
	at com.rabbitmq.client.impl.SocketFrameHandler.readFrame(SocketFrameHandler.java:184)
	at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:665)
	at java.lang.Thread.run(Thread.java:748)

注意检查是不是端口设置错误了

端口应该是 5672 不是15672

		// 1. 创建连接工程
		ConnectionFactory connectionFactory = new ConnectionFactory();
		connectionFactory.setHost("121.89.219.240");
		connectionFactory.setPort(5672);
		connectionFactory.setVirtualHost("/");
		connectionFactory.setUsername("admin");
		connectionFactory.setPassword("admin");

Rabbitmq 相关端口

5672: 	RabbitMQ的通讯端口
25672:	RabbitMQ的节点间的CLI通讯端口是
15672:	RabbitMQ HTTP_API的端口,管理员用户才能访问,用于管理RabbitMQ,需要启动Management插件。
1883,8883:	MQTT插件启动时的端口。
61613、61614:	STOMP客户端插件启用的时候的端口。
15674、15675:	基于webscoket的STOMP端口和MOTT端口

你可能感兴趣的:(报错,rabbitmq,java)