NutzCN Logo
问答 谁用过rabbitmq,发布时会报错
发布于 2710天前 作者 shusheng 6621 次浏览 复制 上一个帖子 下一个帖子
标签:
[AMQP Connection 61.147.116.229:5672] ERROR com.rabbitmq.client.impl.ForgivingExceptionHandler - An unexpected connection driver error occured
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:170)
	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:164)
	at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:578)
	at java.lang.Thread.run(Thread.java:745)

用一个线程去发布消息,间隔20秒,会出现这个错误,但是报错后,发送了几十遍消息,接收消息都没有问题

6 回复

自动重连了吧

应该是nut的rabbitmq连接了一次,我自己又主动连接了一次,导致的

public Channel getChannel() throws Exception{
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost(conf.get("rabbitmq.host"));
        Connection connection = factory.newConnection();
        return connection.createChannel();
    }

"nut的rabbitmq" ?? 用了那个插件??

注入ConnectionFactory嘛, 何须每次新建

@Inject 
ConnectionFactory rabbitmq_cf;

rabbitmq_cf : {
		type : "com.rabbitmq.client.ConnectionFactory",
		factory : "$conf#make",
		args : ["com.rabbitmq.client.ConnectionFactory", "rabbitmq."]
	},

源码中有配置一个ConnectionFactory,修改后正常了,没报错

添加回复
请先登陆
回到顶部